Forums / Setup & design / "Dynamic" left menu

"Dynamic" left menu

Author Message

Krischan Hauschkez

Thursday 09 November 2006 11:09:25 am

Hi!

I need a little help...

I made up a site using a top and a left menu. In the left one there is only one menu level shown. Now I want the next level been shown, too. But only, when I click on the "mother" node. This is how it is now:

1 News
2 Contact
3 Links
4 Things

And when I click on 3, it should be like this:

1 News
2 Contact
3 Links
- Good Links
- Bad Links
- Other Links
4 Things

How could I do that?

TIA!

Jacobo Quiles

Monday 13 November 2006 12:59:36 am

Hi,

You could try something like this:

{def $second_level_children=array()}
{def $root_node_children=fetch('content', 'list', hash('parent_node_id', 2))}

{if gt($root_node_children|count,0)}
<ul>
{foreach $root_node_children as $child}
<li>
<a href={$child.url_alias|ezurl()}>{$child.name|wash()}</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><a href={$child2.url_alias|ezurl()}>{$child2.name|wash()}</a></li>
{/foreach}
</ul>
{/if}
{/if}
<li>
{/foreach}
</ul>
{/if}

First fetch the elements of the top level, foreach element check if it's the node that is being viewed or if it's one of its children's node. If so, show its children.

The code above has not been tested, but maybe would give you an idea on how to do it.

Microblau SL
http://www.microblau.net

Krischan Hauschkez

Monday 13 November 2006 1:03:21 pm

Excellent work, Jacobo, really excellent! Thank you very, very much! I have to modify it a bit, but your code works at it is!

Thankful greetings,
Krischan

kracker (the)

Monday 13 November 2006 1:36:04 pm

I have documented this conversation's question, answer and source code in the <i>eZpedia</i>, <b>eZ publish community documentation</b>

<i>http://pubsvn.ez.no/wiki/en/ez/solution_dynamic_left_menu</i>

Please feel free to update the entry to include the actual tested sourced you used as a solution so all may do so as well ...

Cheers,
//kracker
<i>Modest Mouse - 3rd Planet (radio-edit)</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

eZ debug

Timing: Jan 19 2025 00:20:21
Script start
Timing: Jan 19 2025 00:20:21
Module start 'content'
Timing: Jan 19 2025 00:20:22
Module end 'content'
Timing: Jan 19 2025 00:20:22
Script end

Main resources:

Total runtime0.9837 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.6094180.8438
Module start 'content' 0.00740.8301 768.4531605.1641
Module end 'content' 0.83760.1461 1,373.6172337.4297
Script end 0.9836  1,711.0469 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00490.5009210.0002
Check MTime0.00170.1680210.0001
Mysql Total
Database connection0.00110.107410.0011
Mysqli_queries0.894990.97811990.0045
Looping result0.00230.23021970.0000
Template Total0.947696.320.4738
Template load0.00270.277120.0014
Template processing0.944996.056520.4725
Template load and register function0.00020.024510.0002
states
state_id_array0.00140.140010.0014
state_identifier_array0.00090.093320.0005
Override
Cache load0.00240.2442590.0000
Sytem overhead
Fetch class attribute can translate value0.00160.159440.0004
Fetch class attribute name0.00110.114060.0002
XML
Image XML parsing0.00270.279340.0007
class_abstraction
Instantiating content class attribute0.00000.002060.0000
General
dbfile0.00690.6973360.0002
String conversion0.00000.000930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs