Setting Left menu (treemenu) to another nodeId

Author Message

Alexander Petrov

Wednesday 06 December 2006 7:12:08 am

Hi!

I'm trying to set the left treemenu to another nodeId.
Here is the template code:

{let docs=treemenu( $module_result.path,
                    is_set( $module_result.node_id )|choose( 2, $module_result.node_id ),
                    ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ),
                    0, 5 )
                    depth=1
                    last_level=0}
        <ul>
        {section var=menu loop=$:docs last-value}
            {set last_level=$menu.last|is_array|choose( $menu.level, $menu.last.level )}
            {section show=and( $last_level|eq( $menu.level ), $menu.number|gt( 1 ) )}
                </li>
            {section-else}
            {section show=and( $last_level|gt( $menu.level ), $menu.number|gt( 1 ) )}
                </li>
                    {"</ul>
                </li>"|repeat(sub( $last_level, $menu.level ))}
            {/section}
            {/section}

            {section show=and( $last_level|lt( $menu.level ), $menu.number|gt( 1 ) )}
                {'<ul><li>'|repeat(sub($menu.level,$last_level,1))}
                <ul>
                    <li class="menu-level-{$menu.level}">
            {section-else}
                <li class="menu-level-{$menu.level}">
            {/section}

            <a {$menu.is_selected|choose( '', 'class="selected"' )} href={$menu.url_alias|ezurl}><span class="arrowz">&gt;&gt;</span>&nbsp;  {$menu.text|shorten( 25 )}  &nbsp; </a>

            {set depth=$menu.level}
        {/section}
           </li>

        {section show=sub( $depth, 0 )|gt( 0 ) loop=sub( $depth, 0 )}
            </ul>
        </li>
        {/section}
        </ul>

{/let}

I cannot understand what parameter should be changed for this.
I'v changed from 2 to another nodeid here

is_set( $module_result.node_id )|choose( 2, $module_result.node_id ),

but nothing happened. Menu.ini parameters are not documented yet :(

Can anyone help?

Jon Staines

Friday 08 December 2006 8:02:35 am

The menu.ini setting being used in this template is just set to limit which classes will be included in the menu. The line:

ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' )

means look in menu.ini (and any of the menu.ini overrides or siteaccess files), find the section starting with MenuContentSettings, and look at the value of LeftIdentifierList. So in the menu.ini.append.php for that siteaccess you will find a section called MenuContentSettings similar to:

[MenuContentSettings]
TopIdentifierList[]
TopIdentifierList[]=folder
LeftIdentifierList[]=feedback_form
LeftIdentifierList[]
LeftIdentifierList[]=folder
LeftIdentifierList[]=news_folder

Which would mean that only nodes which were of the class folder or news_folder would appear in the left menu.

I think the

is_set( $module_result.node_id )|choose( 2, $module_result.node_id )

provides some kind of fallback mechanism so that it uses the root node 2 if the module_result is empty. Hopefully somebody else can provide a better explanation for how it works. Its ugly but you could always hard code the node id you want the tree to start at:

{let docs=treemenu( $module_result.path,
                    xxxxx,
                    ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ),
                    0, 5 )
                    depth=1
                    last_level=0}

Where xxxxx is the node id that is the top of the tree.

Olav Bringedal

Thursday 21 December 2006 2:11:04 am

node_id is deprecated from treemenu for newer versions, so changing $module_result.path is the way to go


Senior Consultant
http://Umoe-consulting.no

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.