init_assets
Tag {init_assets} allows you to call out custom assets.
Parameters
- parent - the object's (section, article, asset etc) ID number where to get the custom assets. If parent is not defined, then current page ID is used.
- name - variable name where the returned data is saved. Default value is "assets".
- profile - defines the profile of the custom assets. Value must exactly match the name given to the profile (prev. named as custom asset type) in the site's administration area.
- position - defines the location of assets' list in the page. You can use any numbers for position.
- fields - defines which fields are included in the assets' list. By default all fields are included.
- where - allows to filter the assets' list based on either search query (in form of %string%) or database query.
- order - sorts the asset list by the defined field. Example: order="<fieldname> asc|desc"
- buttons - defines which editing buttons are shown to editor. Values can be "new,edit,hide,move,delete".
- id - allows to call out one specific asset. If id is defined, parent is ignored.
- start - the starting row number to return. 3.3.1
- limit - the number of rows to return. You must use this parameter always with "start" parameter. 3.3.1
- contains - search string, allows fulltext search from all asset fields as %string%. Example: contains="black". 3.3.7
- select - allows to use additional SELECT fields as SQL statement, comma separated list of fields is allowed. Example: {init_assets .. select="CONCAT(firstname,' ',lastname) AS fullname"). 3.3.7
Elements
- id - ID number of the asset.
- parent_id - ID number of parent object.
- title - the title of the asset.
- <attribute> - Attribute is equal to the specific data field of the custom asset type. All attribute-values of the asset can be called out by the name of the attribute. The data field name is defined in the administration area of the site. Note: don't use the translations of the data field names.
- profile_data - the array of the attributes.
- profile - the profile name of the asset.
- details_link - link to the detailed view of the asset.
- details_title - link name of detailed view of the asset.
- date - the date of the creation of the asset in format dd.mm.yyyy
This functionality is deprecated in version 4, please use created_time instead. - fdate - the date of the creation of the asset in format yyyy/mm/dd
This functionality is deprecated in version 4, please use fcreated_time instead. - last_modified - the last modification date of the asset in format dd.mm.yyyy
This functionality is deprecated in version 4, please use changed_time instead. - flast_modified - the last modification date of the asset in format yyyy/mm/dd
This functionality is deprecated in version 4, please use changed_time instead. - created_user_id - user ID who initially created the object. 4.0.3
- created_user_name - user full name who initially created the object. 4.0.3
- changed_user_id - user ID who made the last object saving. 4.0.3
- changed_user_name - user full name who made the last object saving. 4.0.3
- created_time - creating time of the object in format dd.mm.yyyy hh:ii. 4.0.3
- fcreated_time - creating time of the object in database default format, eg yyyy-mm-dd hh:ii. 4.0.3
- changed_time - last saving time of the object in format dd.mm.yyyy hh:ii. 4.0.3
- fchanged_time - last saving time of the object in database default format, eg yyyy-mm-dd hh:ii. 4.0.3
General tags
- <name>_newbutton - prints "New" action-button for creating a new object.
- <name>_count - the number of returned objects. If parameter "limit" is set then this value equals to the "limit" value.
- <name>_counttotal - the total number of objects found, not affected by "limit" parameter. 3.3.7
Example 1
{* This is a demonstration of how to make a template to display list of assets and allow user to click on each to display the detail view *}
{* If the id= in URL belongs to object class "section" ie user has clicked on menu item *}
{if $current_class == "section"}
{init_assets name="industries" profile="Industry"}
{foreach from=$industries item=industry}
{$industry->buttons}
{* Link to the asset detail view. We are passing the template ID to the URL so the CMS knows to use the same template.
If you ommit the tpl= in the URL, the default asset template will be used. You can change that from Admin > Templates > Object templates > Custom Asset dropdonw. If you have different asset types, it would be wise to define on single content template which will check the profile of the asset and display nescessary fields *}
<ahref="?id={$industry->id}&tpl=1086">{$industry->title}</a><br>
{foreachelse}
{$industries_newbutton}
{/foreach}
{* Since our template only has links to the objects class "asset", this must be asset detail view *}
{else}
{* By using id="$id" in init_assets statement, we will find the asset with the ID in the URL *}
{init_assets name="industry" profile="Industry" id="$id"}
{* Since we know there is only one asset with one ID, we will not write foreach statement, but are calling the first element with a Smarty shortcut *}
{$industry.0->title}
{/if}
RSS