Sorting a tree structured menu

Author Message

Bjørn Kaarstein

Wednesday 31 March 2004 4:04:12 am

Hi everybody. Some sorting problems occure:

{let folderlist=fetch('content', 'tree' ,hash('parent_node_id', 2,
				'class_filter_type', include,
				'class_filter_array', array(1)))}

<!-- **************************  HER BEGYNNER MENYEN ***************************** -->

<table border="0" cellspacing="2" cellpadding="0" width="189" class="menu1">

{section name=menu loop=$folderlist}
 {switch match=$menu:item.depth}

  {case match=2} {*Level 2 won't show sub folders*}
   {section show=eq($menu:index, 0)}</td></tr>
   {/section}

     <tr>
     <td class="menu" width="175" height="20">
     <a href={$menu:item.url_alias|ezurl}>{$:item.name}</a>  
  {/case}

  {case match=3} {*Level 3 sows the sub folders*}
   {section show=and($node.depth|ge(2),eq($menu:item.parent_node_id, $node.path_array.2))}
    
<tr>
<td width="175" height="20" class="submenu"><a href={$menu:item.url_alias|ezurl}>{$menu:item.name}</a> 
</td>
</tr>
      
   {/section}
  {/case}
 {/switch}
{/section}
{/let}
</td>
</tr>
</table>

This code produces a menu with submenus. My problem starts as soon as I try to add sorting to my fetch. As it's a tree fetch, all folders on all levels is sorted, and the mainmenu and the subs are displayed on the wrong places.

When I add a folder to my mainmenu, this is displayed on top of all menu items instead of bottom. Any ideas on how to solve this? Will I have to write a completely new code for being able to sort? This site runs on Version: 3.1-1 Revision: 2703.

Regards Bjørn

Balazs Halasy

Wednesday 31 March 2004 6:02:05 am

Hi,

There is a better way of creating menus/submenus: use the "treemenu" operator. I think this is an extension - take a look among contributions (or try searching for "treemenu" on ez.no).

Balazs

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