Webin: Treemenu limited to 2 Levels?

Author Message

Marco Zinn

Saturday 02 February 2008 7:34:12 am

Hi there,

it seems to me, that the Treemenu (Left Menu) in the Webin Design is limited to 2 levels.
Can you confirm this? If so, how can i increase the max depth of the menu? There used to be an ini setting for it, in the old-days treemenu templates. Does it still exist?

Marco
http://www.hyperroad-design.com

Ɓukasz Serwatka

Saturday 02 February 2008 11:03:37 am

Hi,

Yes, left menu support 2 levels. You can override that template in your design extension and add changes there. There is no INI setting that control levels in the left menu.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Noicokuna Niemoge

Thursday 22 January 2009 4:45:36 am

I have a headache...

Please point me the place where I should change the tree depth to make it display up to 5 levels...

<b>flat_left.tpl</b>

<div class="border-box">
<div class="border-tl"><div class="border-tr"><div class="border-tc"></div></div></div>
<div class="border-ml"><div class="border-mr"><div class="border-mc">

        <h4><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $module_result.path[$pagerootdepth].node_id)|ezurl}{else}{$module_result.path[$pagerootdepth].url_alias|ezurl}{/if}>{$module_result.path[$pagerootdepth].text}</a></h4>

{if or(is_unset($module_result.content_info.class_identifier), ne( $module_result.content_info.class_identifier, 'documentation_page' ))}
   {def $root_node=fetch( 'content', 'node', hash( 'node_id', $module_result.path[$pagerootdepth].node_id ) )
        $left_menu_items = fetch( 'content', 'list', hash( 'parent_node_id', $root_node.node_id,
                                                           'sort_by', $root_node.sort_array,
                                                           'class_filter_type', 'include',
                                                           'class_filter_array', ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ) ) )
         $left_menu_items_count = $left_menu_items|count()
         $li_class = array()
         $a_class = array()
         $current_node_in_path_2 = cond(and($current_node_id, $pagedepth|gt($pagerootdepth|inc)), $path_array[$pagerootdepth].node_id, 0  )
         $current_node_in_path_3 = cond(and($current_node_id, $pagedepth|gt($pagerootdepth|sum(2))), $path_array[$pagerootdepth|inc].node_id, 0  )}

        {if $left_menu_items_count}
        <ul class="menu-list">
       {foreach $left_menu_items as $key => $item}
            {set $a_class = cond($current_node_in_path_2|eq($item.node_id), array("selected"), array())
                 $li_class = cond( $key|eq(0), array("firstli"), array() )}

            {if $left_menu_items_count|eq( $key|inc )}
                {set $li_class = $li_class|append("lastli")}
            {/if}
            {if $item.node_id|eq( $current_node_id )}
                {set $a_class = $a_class|append("current")}
            {/if}
               <li{if $li_class} class="{$li_class|implode(" ")}"{/if}><div class="second_level_menu"><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $item.node_id)|ezurl}{else}{$item.url_alias|ezurl}{/if}{if $a_class} class="{$a_class|implode(" ")}"{/if}>{$item.name|wash()}</a></div>

               {if and( is_set( $module_result.path[$pagerootdepth|inc].node_id ), $item.node_id, eq( $module_result.path[$pagerootdepth|inc].node_id, $item.node_id ) )}
               {def $sub_menu_items = fetch( 'content', 'list', hash( 'parent_node_id', $item.node_id,
                                                                     'sort_by', $item.sort_array,
                                                                       'class_filter_type', 'include',
                                                                       'class_filter_array', ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ) ) )
                 $sub_menu_items_count = $sub_menu_items|count}
            {if $sub_menu_items_count}
            <ul class="submenu-list">
               {foreach $sub_menu_items as $subkey => $subitem}
                   {set $a_class = cond($current_node_in_path_3|eq($subitem.node_id), array("selected"), array())
                     $li_class = cond( $subkey|eq(0), array("firstli"), array() )}
                {if $sub_menu_items_count|eq( $subkey|inc )}
                    {set $li_class = $li_class|append("lastli")}
                {/if}
                {if $subitem.node_id|eq( $current_node_id )}
                    {set $a_class = $a_class|append("current")}
                {/if}
                <li{if $li_class} class="{$li_class|implode(" ")}"{/if}><div class="third_level_menu"><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $subitem.node_id)|ezurl}{else}{$subitem.url_alias|ezurl}{/if}{if $a_class} class="{$a_class|implode(" ")}"{/if}>{$subitem.name|wash()}</a></div></li>
               {/foreach}
               </ul>
               {/if}
            {undef $sub_menu_items $sub_menu_items_count}
               {/if}
               </li>
       {/foreach}
        </ul>
        {/if}
   {undef $root_node $left_menu_items $left_menu_items_count $a_class $li_class $current_node_in_path_2 $current_node_in_path_3}
{else}

    <div class="contentstructure">

   {def $current_node=fetch( content, node, hash( node_id, $module_result.node_id ) )
        $chapter_container=fetch( content, node, hash( node_id, $current_node.path_array[$pagerootdepth|inc] ) )
        $class_filter=ezini( 'TreeMenu', 'ShowClasses', 'contentstructuremenu.ini' )
        $depth=is_set( $current_node.path_array[$pagerootdepth|sum(2)] )|choose( $pagerootdepth|sum(3), 0 )
        $node_to_unfold=is_set( $current_node.path_array[$pagerootdepth|sum(2)] )|choose(0 , $current_node.path_array[$pagerootdepth|sum(2)] )
        $contentStructureTree = content_structure_tree( $chapter_container.node_id, $class_filter, $depth, 0, 'false', false(), $node_to_unfold )}

    {include uri='design:simplified_treemenu/show_simplified_menu.tpl' contentStructureTree=$contentStructureTree is_root_node=true() skip_self_node=true() current_node_id=$module_result.node_id unfold_node=$node_to_unfold chapter_level=0}

    {undef $current_node $chapter_container $class_filter $depth $node_to_unfold $contentStructureTree}
    </div>
{/if}

</div></div></div>
<div class="border-bl"><div class="border-br"><div class="border-bc"></div></div></div>
</div>

Shiki soku ze ku...

Luigi Spagnolo

Thursday 22 January 2009 12:57:51 pm

It seems that the left tree menu is based on two foreach loops nested ().
The outer foreach takes care of displaying the items of the first level (and fetches the items of the second level):

<ul class="menu-list">
       {foreach $left_menu_items as $key => $item}
      ...
       {/foreach}

the inner foreach displays the items of the second level:

 

               {foreach $sub_menu_items as $subkey => $subitem}
                  ...
               {/foreach}

So you should add your main code right before the closure tag of the inner foreach loop; first you fetch the third level nodes (checking if it is necessary with a if block) , then add a third nested foreach loop to display them (checking if it is necessary with a if block) ; analogously you can add the fourth and fifth levels...

Consider that you may also need to determine the current nodes in path...

 $current_node_in_path_2 = cond(and($current_node_id, $pagedepth|gt($pagerootdepth|inc)), $path_array[$pagerootdepth].node_id, 0  )
         $current_node_in_path_3 = cond(and($current_node_id, $pagedepth|gt($pagerootdepth|sum(2))), $path_array[$pagerootdepth|inc].node_id, 0  )}

$current_node_in_path_3 = cond(and($current_node_id, $pagedepth|gt($pagerootdepth|sum(3))), $path_array[$pagerootdepth|sum(2)].node_id, 0  )}
...

 

Noicokuna Niemoge

Friday 23 January 2009 12:05:08 am

Thank you for reply, it's priceless!

Shiki soku ze ku...

Marco Zinn

Friday 23 January 2009 10:28:29 am

As i see, that this issue still is open in ez 3, I'd like to share our solution with you.

This is the flat_left.tpl, that we are using on ez 3.10 in order to show one more menu level.
Please note, that we removed the special handling of the "documentation" class, which is in the original template, as we didn't need it.

If you want to merge our modifications to the original or your template, search for "Hyperroad Design" to find the added lines


{*?template charset=utf-8?*}
<div class="border-box">
<div class="border-tl"><div class="border-tr"><div class="border-tc"></div></div></div>
<div class="border-ml"><div class="border-mr"><div class="border-mc">

        <h4><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $module_result.path[$pagerootdepth].node_id)|ezurl}{else}{$module_result.path[$pagerootdepth].url_alias|ezurl}{/if}>{$module_result.path[$pagerootdepth].text}</a></h4>

   {def $root_node=fetch( 'content', 'node', hash( 'node_id', $module_result.path[$pagerootdepth].node_id ) )
        $left_menu_items = fetch( 'content', 'list', hash( 'parent_node_id', $root_node.node_id,
                                                           'sort_by', $root_node.sort_array,
                                                           'class_filter_type', 'include',
                                                           'class_filter_array', ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ) ) )
         $left_menu_items_count = $left_menu_items|count()
         $li_class = array()
         $a_class = array()
         $current_node_in_path_2 = cond(and($current_node_id, $pagedepth|gt($pagerootdepth|inc)), $path_array[$pagerootdepth].node_id, 0  )
         $current_node_in_path_3 = cond(and($current_node_id, $pagedepth|gt($pagerootdepth|sum(2))), $path_array[$pagerootdepth|inc].node_id, 0  )
         $current_node_in_path_4 = cond(and($current_node_id, $pagedepth|gt($pagerootdepth|sum(3))), $path_array[$pagerootdepth|inc|inc].node_id, 0  )
		 }
{* Hypperroad Design: Defined $current_node_in_path_4 for the additional menu level *}

        {if $left_menu_items_count}
        <ul class="menu-list">
       {foreach $left_menu_items as $key => $item}
            {set $a_class = cond($current_node_in_path_2|eq($item.node_id), array("selected"), array())
                 $li_class = cond( $key|eq(0), array("firstli"), array() )}

            {if $left_menu_items_count|eq( $key|inc )}
                {set $li_class = $li_class|append("lastli")}
            {/if}
            {if $item.node_id|eq( $current_node_id )}
                {set $a_class = $a_class|append("current")}
            {/if}
               <li{if $li_class} class="{$li_class|implode(" ")}"{/if}><div class="second_level_menu"><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $item.node_id)|ezurl}{else}{$item.url_alias|ezurl}{/if}{if $a_class} class="{$a_class|implode(" ")}"{/if}>{$item.name|wash()}</a></div>

               {if and( is_set( $module_result.path[$pagerootdepth|inc].node_id ), $item.node_id, eq( $module_result.path[$pagerootdepth|inc].node_id, $item.node_id ) )}
               {def $sub_menu_items = fetch( 'content', 'list', hash( 'parent_node_id', $item.node_id,
                                                                     'sort_by', $item.sort_array,
                                                                       'class_filter_type', 'include',
                                                                       'class_filter_array', ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ) ) )
                 $sub_menu_items_count = $sub_menu_items|count}
            {if $sub_menu_items_count}
            <ul class="submenu-list">
               {foreach $sub_menu_items as $subkey => $subitem}
                   {set $a_class = cond($current_node_in_path_3|eq($subitem.node_id), array("selected"), array())
                     $li_class = cond( $subkey|eq(0), array("firstli"), array() )}
                {if $sub_menu_items_count|eq( $subkey|inc )}
                    {set $li_class = $li_class|append("lastli")}
                {/if}
                {if $subitem.node_id|eq( $current_node_id )}
                    {set $a_class = $a_class|append("current")}
                {/if}
                <li{if $li_class} class="{$li_class|implode(" ")}"{/if}><div class="third_level_menu"><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $subitem.node_id)|ezurl}{else}{$subitem.url_alias|ezurl}{/if}{if $a_class} class="{$a_class|implode(" ")}"{/if}>{$subitem.name|wash()}</a></div></li>

{* Hyperroad Design: Render additional menu level *}

               {if and( is_set( $module_result.path[$pagerootdepth|inc|inc].node_id ), $subitem.node_id, eq( $module_result.path[$pagerootdepth|inc|inc].node_id, $subitem.node_id ) )}
               {def $sub3_menu_items = fetch( 'content', 'list', hash( 'parent_node_id', $subitem.node_id,
                                                                     'sort_by', $subitem.sort_array,
                                                                       'class_filter_type', 'include',
                                                                       'class_filter_array', ezini( 'MenuContentSettings', 'LeftIdentifierList', 'menu.ini' ) ) )
                 $sub3_menu_items_count = $sub3_menu_items|count}
             {if $sub3_menu_items_count}
            <ul class="submenu-list">
               {foreach $sub3_menu_items as $sub3key => $sub3item}
                   {set $a_class = cond($current_node_in_path_4|eq($sub3item.node_id), array("selected"), array())
                     $li_class = cond( $sub3key|eq(0), array("firstli"), array() )}
                {if $sub3_menu_items_count|eq( $sub3key|inc )}
                    {set $li_class = $li_class|append("lastli")}
                {/if}
                {if $sub3item.node_id|eq( $current_node_id )}
                    {set $a_class = $a_class|append("current")}
                {/if}
                <li{if $li_class} class="{$li_class|implode(" ")}"{/if}><div class="forth_level_menu"><a href={if eq( $ui_context, 'browse' )}{concat("content/browse/", $sub3item.node_id)|ezurl}{else}{$sub3item.url_alias|ezurl}{/if}{if $a_class} class="{$a_class|implode(" ")}"{/if}>{$sub3item.name|wash()}</a></div></li>
               {/foreach}
               </ul>
               {/if}
            {undef $sub3_menu_items $sub3_menu_items_count}			   
               {/if}
{* Hyperroad Design: End of modification *}
 
               </li>
                {/foreach}
               </ul>
               {/if}
            {undef $sub_menu_items $sub_menu_items_count}
               {/if}
               </li>
       {/foreach}
        </ul>
        {/if}
   {undef $root_node $left_menu_items $left_menu_items_count $a_class $li_class $current_node_in_path_2 $current_node_in_path_3 $current_node_in_path_4}


</div></div></div>
<div class="border-bl"><div class="border-br"><div class="border-bc"></div></div></div>
</div>

Maybe this is of help for some of you.

Marco
http://www.hyperroad-design.com

Noicokuna Niemoge

Monday 26 January 2009 1:20:51 am

Indeed it helped! Thanks!

Shiki soku ze ku...

Gary Teh

Monday 26 January 2009 2:50:05 am

Nice! I was just thinking of doing some extensions to the left tree menu as well myself. Saved me time looking around for the code. Thanks for pointing me in the right direction.

http://name1price.com : Get a Cool website for yourself and also learn how to manage it. It is easy. Use it to get more customers for your business.

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