Left menu sub-items

Author Message

Alexander Petrov

Monday 18 December 2006 3:23:16 am

Hello!

I'm using this template for displaying folder items and sub-items:

{def $second_level_children=array()}
{def $root_node_children=fetch('content', 'list', hash('parent_node_id', 119,  'sort_by', array('name', true())))}
 
{if gt($root_node_children|count,0)}
<ul>
{foreach $root_node_children as $child}
<li class="menu-level-0">
<a href={$child.url_alias|ezurl()}><span class="arrowz">&gt;&gt;</span>&nbsp; {$child.name|wash()} &nbsp;</a>
{if or(eq($child.node_id,$module_result.node_id),eq($module_result.path.1,$child.node_id))}
{set $second_level_children=fetch('content','list',hash('parent_node_id', $child.node_id))}
{if gt($second_level_children|count,0)}
<ul>
{foreach $second_level_children as $child2}
<li class="menu-level-1"><a href={$child2.url_alias|ezurl()}><span class="arrowz">&gt;</span>&nbsp; {$child2.name|wash()} &nbsp;</a></li>
{/foreach}
</ul>
{/if}
{/if}
{/foreach}
</ul>
{/if}

The content tree for this menu is looking like this :

// Root
 --- item 
 --- item 
     -- sub-item
     -- sub-item
     -- etc...

 --- item 
 --- item 
 --- item 
 --- etc..

When I'm opening sub-folder the sub-subitems are displaying in the left menu, but when I click on sub-subitem folder the menu is displaying only the contents of the root folder.
How to make this code to fetch the subitems while viewing the sub-sub folder?

Jon Staines

Monday 18 December 2006 5:46:03 am

In your if statement, try changing the $module_result.path.1 into $module_result.path.1.node_id

Alexander Petrov

Tuesday 19 December 2006 3:15:22 am

Hello Jon!

I'v changed the statement so it looks now like this:

{if or(eq($child.node_id,$module_result.node_id),eq($module_result.path.1.node_id,$child.node_id))}

But there's no effect, them menu behaviour is the same. ((

Jon Staines

Tuesday 19 December 2006 3:50:03 am

Sorry, when testing it I had set the root node id of the menu to 2, whereas you have a folder further down. You need to change the part of the path you need depending on how deep the root folder is.

If you had:

--root
  --news
    --test folder
      --child folder
        --deep folder
    --another folder
  --polls

and you wanted the left menu to look within the news folder instead of root, you would need:

$module_result.path.2.node_id

instead of:

$module_result.path.1.node_id

Just increase the number the more layers down you go.
Hope this makes sense.

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