ez.no / exponential / documentation / reference / template operators / miscellaneous / treemenu
treemenu( path,
node_id,
[ class_filter, ]
[ depth_skip, ]
[ max_level ] )
| Name | Type | Description | Required |
|---|---|---|---|
| path | array | An array of the path, normally uses $module_result.path. | yes |
| node_id | integer | The current node id. | yes |
| class_filter | array | An array of classes to filter on. | no |
| depth_skip | integer | Skip the first x levels. | no |
| max_level | integer | Go maximum to this depth. | no |
An array of arrays to build a menu
The array returned from this function is defined as follows:
array( 'id' => integer, 'level' => integer, 'url_alias' => string, 'url' => string, 'text' => string, 'is_selected' => boolean );
These examples are from pagelayout.tpl.
Make a menu of folder and info_page classes Skip the first level and maximum go to depth 6.
<ul> {let mainMenu=treemenu( $module_result.path, $module_result.node_id, array('folder','info_page'), 1, 6 )} {section var=menu loop=$mainMenu} {section show=$menu.item.is_selected} <li class="level_{$menu.item.level}"> <div class="selected"> <a href={$menu.item.url_alias|ezurl}>{$menu.item.text}</a> </div> </li> {section-else} <li class="level_{$menu.item.level}"> <a href={$menu.item.url_alias|ezurl}>{$menu.item.text}</a> </li> {/section} {/section} {/let} </ul>
Make a menu with correct list representation.
{let docs=treemenu( $module_result.path, $module_result.node_id, array( 9 ), 2, 5 ) depth=1} <ul> {section var=menu loop=$:docs last-value} {section show=and($menu.last.level|gt($menu.level),$menu.number|gt(1))} </ul> </li> {/section} <li> {section show=and($menu.last.level|lt($menu.level),$menu.number|gt(1))} <ul> <li> {/section} {set depth=$menu.level} <a {$menu.is_selected|choose('','class="selected"')} href={$menu.url_alias|ezurl}>{$menu.text|shorten(25)}</a> </li> {/section} </ul> {section show=$depth|gt(1) loop=$depth|sub(1)} </li> </ul> {/section} {/let}
Log in or create a user account to comment.
Comments