Content Smarty Functions
Content Functions refers specifically to methods by which you can access the content configured in the Aurora Back-end under Content > All Content, including Content Pages and Blogs, but not presently Vacancies.
Using the functions described in this article it is possible to add a fully functional blog section into any template throughout the Aurora Front-end. This article is intended to describe what Smarty functions are available for this, how to use them and provide a few examples to get you started. You should refer to the Aurora Demo Example templates detailed with each section for more comprehensive working examples, but none of the examples are provided with any support and are for reference only.
Overview
The functions described in this section allows you to place content or entire blog interfaces into any Template on the Aurora Front-end.
This article should be used in conjunction with the Ajax Content Page article in order to support some of the features including, but not limited to, placing comments on a Content Page/Blog Post.
Listing Blog posts / Content pages (contentFind)
Example URL:
- https://demo.auroracommerce.com/blog/2015/08/example-sub-blog
- https://demo.auroracommerce.com/smarty-search
It is possible to list your Blog posts, Content pages or Blog posts + Content pages anywhere in Aurora using the contentFind function.
Accepted Parameters
Parameter | Values | Default | Description | Required | Sample |
---|---|---|---|---|---|
item | String | blog_posts | This is the name of the variable you would like the results of you query placed in. For example, if you set this to "posts" then the items returned by this method will be loaded into a $posts template variable. | No | blog_posts |
type | content | blog | all | all | Specifies the page type to filter | No | all |
page | Positive Integer | 1 | The number of the page of results you would like to have returned. | No | 1 |
items_per_page | Positive Integer | "Posts per page" setting located under Store -> Settings -> Blog | The number of content items to return per page. | No | 5 |
limit | Positive Integer | "Posts per page" setting located under Store -> Settings -> Blog | The number of content items to return in this request. | No | 5 |
start | Positive Integer | 1 | The number of the content item to start returning in this request. | No | 1 |
search | String | The search term or phrase by which to search the Content items for by title, content and keywords. | No | iPhone | |
search_field_called | String | The case-insensitive name of the Content Field to search. | No | color | |
search_field_for | String | The case-insensitive value to search for in the field described by the search_field_called parameter. | No | red | |
category_id | Positive Integer | The Internal ID Aurora uses to identify a Content Category. | No | 1 | |
parent_content_id | Positive Integer | The Internal ID Aurora uses to identify a Content Item (Blog Post/Content Page). | No | 5 | |
exclude_content_id | Positive Integer | The Internal ID Aurora uses to identify a Content Item (Blog Post/Content Page). | No | 2 | |
exclude_content_ids | Array of Positive integers | This operates in the same way as exclude_content_id, however a list of IDs can be provided. | |||
tags | Comma-delimited String | This comma-delimited string of tags will have Aurora return only content that has any one of the provided tags attached to it. | No | phone,mobile | |
date_start | String (yyyy-mm-dd) | Filters items which were created on or after the date provided. | No | 2016-02-20 | |
date_end | String (yyyy-mm-dd) | Filters items which were created on or before the date provided. | No | 2016-03-15 | |
author_id | Positive integer | The Internal ID Aurora uses to identify a User. | No | 1 | |
order_by | date_created or title or views or relevance | date_created | The name of the field by which the Content should be ordered when returning the recordset. | No | title |
order_by_ascending | false | true | false | If set to 'true', then the content items are returned in Ascending order, otherwise they are returned in Descending order. | No | true |
Data Returned
Field | Values | Description |
---|---|---|
| Array( content_item ) | The data returned by this function is saved to the variable named in the item parameter. |
[item]_total_items | Non-negative Integer | The total number of items found by this function is saved to the variable named in the item parameter with the addition of "_total_items". |
[item]_more_available | Boolean | Whether or not there are more items to be returned that were not returned by this request is saved to the variable named in the item parameter with the addition of "_total_items". |
[item]_number_of_pages | Non-negative Integer | The number of pages available for your request is saved to the variable named in the item parameter with the addition of "_number_of_pages". |
[item]_request | Collection | The collection of request parameters. These parameters must be provided in the form as data elements for pagination to work correctly |
[ item ]_request.items_per_page | Positive integer | See Accepted Parameters section above |
[ item ]_request.page_number | Positive integer | See Accepted Parameters section above |
[ item ]_request.exclude_content_id | Positive integer | See Accepted Parameters section above |
[ item ]_request.parent_content_id | Positive integer | See Accepted Parameters section above |
[ item ]_request.search | String | See Accepted Parameters section above |
[ item ]_request.search_field_called | String | See Accepted Parameters section above |
[ item ]_request.search_field_for | String | See Accepted Parameters section above |
[ item ]_request.author_id | Positive integer | See Accepted Parameters section above |
[ item ]_request.date_start | String (yyyy-mm-dd) | See Accepted Parameters section above |
[ item ]_request.date_end | String (yyyy-mm-dd) | See Accepted Parameters section above |
[ item ]_request.order_by_ascending | String | See Accepted Parameters section above |
[ item ]_request.order_by | String | See Accepted Parameters section above |
[ item ]_request.category_id | Positive integer | See Accepted Parameters section above |
[ item ]_request.tags | Comma-delimited String | See Accepted Parameters section above |
[ item ]_request.type | ||
content_item | Container | An array of fields pertaining to a single content item. |
content_item.id | Positive Integer | The Internal ID Aurora uses to identify Content. |
content_item.title | String | The title of the Blog. |
content_item.page_introduction | String | |
content_item.page_content | String | The main body of the content itself. |
content_item.page_comments | Non-negative Integer | The number of comments a Content Item has received. |
content_item.meta_title | String | Meta title |
content_item.meta_description | String | Meta description |
content_item.meta_keywords | String | Meta keywords |
content_item.date_created | The date this Post was created. | |
content_item.count_views | Non-negative Integer | The number of views this Post has received. |
content_item.comment_status | Whether or not the Blog is currently open for receiving comments. | |
content_item.page_filename | String | The filename used for a Blog's URL. |
content_item.permalink | String | The relative URL used to access an individual blog article on the Front-end. |
content_item.content_complete_url | String | The relative URL for a blog entry. |
content_item.author | Container | This is a container for the Author data. |
content_item.author.id | Positive Integer | The Internal ID Aurora uses to identify Users. |
content_item.author.firstname | String | The first name of the User that is attributed with the creation of the Content Item. |
content_item.author.lastname | String | The last name (surname) of the User that is attributed with the creation of the Content Item. |
content_item.author.fields | Array( String ) | This is an associative array of fields associated to the Author of the Content Item. There will be one entry in this array for each field configured against the Author/User. These fields can vary wildly and are dependant on how Aurora is being used. |
content_item.author.fields.xxx | Variable | |
content_item.fields | Array( String ) | This is an associative array of fields associated to the Content Item. There will be one entry in this array for each field configured against the Blog. |
content_item.fields.xxx | Variable | |
content_item.tags | Array( content_tag ) | For more details regarding the fields available here, please see the content_tag variable in the Content Blog Tags article. |
content_item.categories | Array( content_category ) | For more details regarding the fields available here, please see the content_category variable in the Content Blog Categories article. |
Example template code
You can add the following to the selected content's page in Aurora backend :
<p>Sample content find</p>
{contentFind items_per_page="3" item="items" type="content" search="us" exclude_content_ids=[123,124]}
{include file="content/content-find.tpl.html"}
This template (or its content) can be included in any Front-end Template to list your Blog entries and supports all of the following via the Ajax provided by _js/blog.js:
- Paging (Next and Previous pages only)
- Filtering by:
- Content Category
- Date (Month)
- Content Field (Only one field can be filtered by at any one time)
- Sorted by:
- Date created
- Title
- Views
Updated 14 days ago