Tree Menu Mod

Author Message

David Jones

Thursday 19 October 2006 4:45:15 am

I'm using the tree menu to good effect (default template). Very useful.
However I wish to change the output slightly.

Currently this is what I have.

1.1
1.2
1.3
1.4

1.2 is clicked

1.1
1.2
   1.2.1
   1.2.2
1.3
1.4

1.2.1 is clicked

1.1
1.2
   1.2.1
      1.2.1.1
      1.2.1.2
   1.2.2
1.3
1.4

1.2.1.1 is clicked

1.1
1.2
   1.2.1
      1.2.1.1
          1.2.1.1.1
      1.2.1.2
   1.2.2
1.3
1.4

What I want to see at this stage is only the parent path, siblings, and children.

I want it to look like this:

1.2
   1.2.1
      1.2.1.1
         1.2.1.1.1
      1.2.1.2

can this be done?

Claudia Kosny

Thursday 19 October 2006 10:27:16 am

Hi David

First you need to specify exactly when the other menu entries should disappear. Is it once you reached the maximum depth or a depth of 4 or something else?
And why does the menu entry 1.2.1.2 appear here? It is neither a parent, a sibling or a child of 1.2.1.1.1.

1.2
  1.2.1
     1.2.1.1
        1.2.1.1.1
     1.2.1.2

Also please tell me the full name of the template you use (including the path starting with design)?

Greetings from Luxembourg

Claudia

David Jones

Friday 20 October 2006 12:45:48 am

Claudia

I want to display all parents / grand parents for the path to the selected page.
The pages siblings
the pages children

SO from the example above:

1.2
   1.2.1
      1.2.1.1 (selected)
          1.2.1.1.1
      1.2.1.2

I'm including this in the page layout template.

Thanks

Claudia Kosny

Friday 20 October 2006 2:01:11 am

Ah, out of some strange reasons I thought that 1.2.1.1.1 was selected - sorry.

Although you could use the treemnu for that you would have to do quite a ot of checking whether you want to display a certain item or not as the treemenu can be limited only in the depth, not in the width.

I think the easiest way would be to use the $module_result.path as this contains the names and urls of all parent nodes. Then you would need to fetch the siblings and the children.
So the result would be something like this (this is even a bit tested as I have done this for me a while ago):

{if is_set($module_result.node_id)}
 <ol>
 {foreach $module_result.path as $path_item}
  {if $path_item.url}
   <li><a class="parent" href={$path_item.url|ezurl()}>{$path_item.text|wash()}</a>
    <ol>
  {/if}
 {/foreach}
 
 {* now fetch the siblings and children of the current node *}
 {def $current_node = fetch('content', 'node', hash('node_id', $module_result.node_id))}
 {def $siblings = fetch('content', 'list', hash('parent_node_id', $current_node.parent_node_id,
                                                'sort_by', $current_node.parent.sort_array))}
 {foreach $siblings as $sibling}
  {* if the current node, fetch children *}
  {if $sibling.node_id|eq($current_node.node_id)}
   <li><a class="sibling" href={$sibling.url_alias|ezurl()}>{$sibling.name} </a>
   {def $children = fetch('content', 'list', hash('parent_node_id', $current_node.node_id,
                                                  'sort_by', $current_node.sort_array))}
   {if $children}
    <ol>
    {foreach $children as $child}
     <li><a class="child" href={$child.url_alias|ezurl()}>{$child.name} </a></li>
    {/foreach}
    </ol>
   {/if}
   </li>
  {else}
   <li><a class="sibling" href={$sibling.url_alias|ezurl()}>{$sibling.name} </a></li>
  {/if}
 {/foreach}
 </ol>
 
 {* we have opened count($module_result.path)|sub(1) li and ol which we need to close again *}
 {def $ol_cnt = count($module_result.path)|sub(1)}
 {for 1 to $ol_cnt as $cnt}
   </li>
  </ol>  
 {/for}
{/if}

Hope it helps

Claudia

David Jones

Friday 20 October 2006 3:48:51 am

THanks!

This is excellent.

I wonder, is it possible to skip the first 2 levels of the navigation.

so instead of outputting

1
   1.1
      1.1.1
         1.1.1.1

It outputs

1.1.1
     1.1.1.1

Claudia Kosny

Friday 20 October 2006 4:07:24 am

Just skip the first two iterations for where the module_result.path is looped through and remember that this changes the number of opened ol and li so you need to change the last loop as well. Not sure whether this will have the desired result but as the code is fairly easy just play with a bit to learn how it works.

Claudia

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 19 2025 03:24:23
Script start
Timing: Jan 19 2025 03:24:23
Module start 'layout'
Timing: Jan 19 2025 03:24:23
Module start 'content'
Timing: Jan 19 2025 03:24:24
Module end 'content'
Timing: Jan 19 2025 03:24:24
Script end

Main resources:

Total runtime1.3378 sec
Peak memory usage4,096.0000 KB
Database Queries66

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.0313152.6094
Module start 'layout' 0.00670.0040 741.640639.3984
Module start 'content' 0.01071.3258 781.0391519.1094
Module end 'content' 1.33650.0013 1,300.148416.2031
Script end 1.3378  1,316.3516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2533160.0002
Check MTime0.00140.1011160.0001
Mysql Total
Database connection0.00070.050610.0007
Mysqli_queries1.264594.5177660.0192
Looping result0.00080.0607640.0000
Template Total1.278195.520.6390
Template load0.00270.200820.0013
Template processing1.275495.332220.6377
Template load and register function0.00030.018810.0003
states
state_id_array0.00230.170810.0023
state_identifier_array0.00230.172720.0012
Override
Cache load0.00210.1552530.0000
Sytem overhead
Fetch class attribute can translate value0.00100.077120.0005
Fetch class attribute name0.00230.169960.0004
XML
Image XML parsing0.00040.030220.0002
class_abstraction
Instantiating content class attribute0.00000.001660.0000
General
dbfile0.00620.4640100.0006
String conversion0.00000.002840.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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
10content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 40
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs