init_section
Tag {init_section} allows developers to create navigation menus. It calls out hierarchical objects - sections.
Parameters
- level - level of the hierarchy where to get sections. If level is undefined, sub-sections of current level (based on object ID in URL) are displayed.
- parent - section ID, which sub-sections will be displayed. If parent is undefined, sub-sections of current page ID are displayed.
- name - variable name where the returned data is saved. Default value is "section".
- position - location of sections on the page. You can use any numbers for position. Position number of sections in Saurus CMS default menu is 0.
- classes - defines the object types displayed in menu. Possible values are: "section, link".
If not defined then value "section" is used by default. - buttons - defines which action buttons are displayed to the site editor. Values can be "new,edit,hide,move,delete".
- start - the starting row number to return.
- limit - the number of rows to return. You must use this parameter always with "start" parameter.
- metadata - defines the metadata ID. Only used when metadata sets exist in a database.
This functionality is deprecated in version 4, please use profiles instead. - order - defines how sections are sorted. Sections can be sorted by section title, date, etc with descending or ascending order. Sample: order= "title desc". 3.3.2
- on_create - allows to publish all objects immediately. If the parameter has value "on_create=publish", then a created object is published immediately. Default value is "hide". 4.0.2
Note 1: Make sure that once you have already created sections with certain position number, don't change the position number in the template, since you will "hide" all sections inserted with previous position number. For example, if you have created sections with position "0" and later change it to "10", all sections inserted between this change have position number "0" and they won't appear on a page under position "10".
Attributes
- id - section ID number
- parent_id - ID number of parent object
- href - link to section, e.g. index.php?id=234
- title - title of section
- is_selected - value is 1 if section is active (selected), 0 otherwise
- buttons - action-buttons for section editing, available only for authorized editors.
- last modified - the section's last modified time.
This functionality is deprecated in version 4, please use "changed_time" instead. - class - class name of the object. The possible values for {$obj->class} are: "section, article, link, image, comment, poll, document, article's list, link list, login-box, subject, album, iframe-box, event"
- 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
- comment_count - the number of comments. 4.0.6
- last_commented_time - the last comment time in format dd.mm.yyyy hh:ii. 4.0.6
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
Examples
Current level sections
{init_section}
{foreach from=$section item=obj}
{$obj->title}
{/foreach}
2nd level sections with action-buttons. In case there are no sections in this level, "N-button" will be displayed
{init_section name="rub2" level="2"}{foreach from=$rub2 item=obj}
{$obj->buttons}{$obj->title}<br>
{foreachelse}
{$rub2_newbutton}
{/foreach}
2nd level sections with links and action-buttons. Active section is displayed in red.
{init_section name="rub2" level="2"}
{foreach from=$rub2 item=obj}
{$obj->buttons}
{if $obj->is_selected}
<a href="{$obj->href}">{$obj->title}</a>
{else}
<a href="{$obj->href}">{$obj->title}</a>
{/if}
<br>
{foreachelse}
{$rub2_newbutton}
{/foreach}
Tree-menu
{init_section name="rub1" level="1"}
<ul>
{foreach from=$rub1 item=obj1}
<li>
{init_section name="rub2" parent=$obj1->id}
<a href="{$obj1->href}">{$obj1->title}</a>
{if $obj1->is_selected}
<ul>
{foreach from=$rub2 item=obj2}
<li>
{init_section name="rub3" parent=$obj2->id}
<a href="{$obj2->href}">{$obj2->title}</a>
{if $obj2->is_selected}
<ul>
{foreach from=$rub3 item=obj3}
<li>
<a href="{$obj3->href}">{$obj3->title}</a>
</li>
{/foreach}
</ul>
{/if}
</li>
{/foreach}
</ul>
{/if}
</li>
{/foreach}
</ul>
2nd level menu, starting from 2nd element.
{init_section name="rub2" level="2"}
<ul>
{foreach from=$rub2 item=obj2 name="rub2_loop"}
{if !$smarty.foreach.rub2_loop.first}
<li>{$obj->buttons}<a href="{$obj->href}">{if $obj->is_selected}<b>{/if}{$obj->title}
{if $obj->is_selected}</b>{/if}</a></li>
{/if}
{foreachelse}
{$rub2_newbutton}
{/foreach}
</ul>
RSS