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.

eZ debug

Timing: Jan 18 2025 15:51:16
Script start
Timing: Jan 18 2025 15:51:16
Module start 'layout'
Timing: Jan 18 2025 15:51:16
Module start 'content'
Timing: Jan 18 2025 15:51:17
Module end 'content'
Timing: Jan 18 2025 15:51:17
Script end

Main resources:

Total runtime1.2760 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.9141152.6250
Module start 'layout' 0.00550.0029 740.539139.4609
Module start 'content' 0.00841.2664 780.0000495.6250
Module end 'content' 1.27470.0013 1,275.62508.3203
Script end 1.2760  1,283.9453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2404160.0002
Check MTime0.00130.0991160.0001
Mysql Total
Database connection0.00060.048810.0006
Mysqli_queries1.236596.9045540.0229
Looping result0.00040.0344520.0000
Template Total1.243897.520.6219
Template load0.00190.147020.0009
Template processing1.241997.325420.6210
Template load and register function0.00010.009310.0001
states
state_id_array0.00160.127410.0016
state_identifier_array0.00180.139720.0009
Override
Cache load0.00150.1213130.0001
Sytem overhead
Fetch class attribute can translate value0.00070.051920.0003
Fetch class attribute name0.00080.060530.0003
XML
Image XML parsing0.00050.042920.0003
class_abstraction
Instantiating content class attribute0.00000.000530.0000
General
dbfile0.00070.0549160.0000
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 9
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs