treemenu

Summary

Fetches a node subtree for display as a tree menu.

Usage

treemenu( path, 
              node_id,
              [ class_filter, ]
              [ depth_skip, ]
              [ max_level ] )

Parameters

NameTypeDescriptionRequired
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

Returns

An array of arrays to build a menu

Description

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 );

Examples

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}

Comments

Log in or create a user account to comment.

Contents

Reference

Database diagram
Template operators
    PDF
    Arrays
    Data extraction
    Formatting
    Images
    Logic
    Mathematics
    Miscellaneous
       month_overview
       attribute
       treemenu
    Strings
    URLs
    Variables
Template functions
Data fetching
Modules
XML tags


Created

05/02/2004
11:51:14 am
by Balazs Halasy

Last updated

06/05/2004
2:44:05 pm
by Bj�rn Dieding@xrow.de

Authors

Balazs Halasy
B�rd Farstad
Bj�rn Dieding@xrow.de



This page is part of the Exponential documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.