tree menu with hidden first level

Author Message

christian leu

Friday 16 July 2004 2:39:18 am

i use the following code for my menu on www.proeda.net.

as i like to make the site multilingual and will not use the translation feature, i need a solution to start the menu on root, but dont show the first level. could anyone help me with this?

{* Set your top category here *}
{let top_cat=114 counter=0 flag_section2=0 flag_section2=0
     used_node=false() teststring=""}

{* See if we have already a node id otherwise use the top category as current node *}
{section show=is_set($DesignKeys:used.node)}
        {set used_node=$DesignKeys:used.node}
{section-else}
        {set used_node=$top_cat}
{/section}

{* Get a proper node object *}
{let node_obj=fetch(content,node,hash(node_id,$used_node))}




{* FIRST LEVEL *}
{section loop=fetch(content,list,hash(parent_node_id,$top_cat, class_filter_type, "include", class_filter_array, array(1,2,3,8,10),sort_by,array(array(priority))))}
{set counter=$:counter|inc}
{set flag_section2=0}
{set flag_section3=0}
	{section name=ultop show=$:counter|eq(1)}
	<ul id="menutop">
	{/section}
	{section name=ulrest show=$:counter|eq(2)}
	</ul>
	<ul id="menu">
	{/section}
	 
	{section show=eq($:item.node_id,$used_node)}
		<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} class="navactive"><img src={"square_red.gif"|ezimage} width="7" height="7" border="0" alt="NavigationSquare">{$:item.name}</a>
	{section-else}
		{section show=$node_obj.path_array|contains($:item.node_id)}
			<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} class="navactive"><img src={"square_red.gif"|ezimage} width="7" height="7" border="0" alt="NavigationSquare">{$:item.name}</a>
		{section-else}
			<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} class="nav"><img src={"square_grey.gif"|ezimage} width="7" height="7" border="0" alt="NavigationSquare">{$:item.name}</a>
		{/section}
	{/section}

	{* SECOND LEVEL *}
	{section show=$node_obj.path_array|contains($:item.node_id)}
		{set flag_section2=1}
		<ul class="submenu">
	{/section}
	{section show=$node_obj.path_array|contains($:item.node_id) loop=fetch(content,list,hash(parent_node_id,$:item.node_id, class_filter_type, "include", class_filter_array, array(1,2,3,8,10),sort_by,array(array(priority))))}
		{section show=eq($:item.node_id,$used_node)}
			<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} class="subnavactive"><img src={"square_red.gif"|ezimage} width="7" height="7" border="0" alt="NavigationSquare">{$:item.name}</a>
		{section-else}
			{section show=$node_obj.path_array|contains($:item.node_id)}
				<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} class="subnavactive"><img src={"square_red.gif"|ezimage} width="7" height="7" border="0" alt="NavigationSquare">{$:item.name}</a>
			{section-else}
				<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} class="subnav"><img src={"square_grey.gif"|ezimage} width="7" height="7" border="0" alt="NavigationSquare">{$:item.name}</a>
			{/section}
		{/section}

		{* THIRD LEVEL *}
		
		{section show=$node_obj.path_array|contains($:item.node_id) loop=fetch(content,list,hash(parent_node_id,$:item.node_id, class_filter_type, "include", class_filter_array, array(1,2,3,8,10),sort_by,array(cond($:item.node_id|ne(117),array("priority"),array("published",false())))))}
			<ul class="submenu2">
			{section show=eq($:item.node_id,$used_node)}
				<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} class="subnavactive2"><img src={"square_red.gif"|ezimage} width="7" height="7" border="0" alt="NavigationSquare">{$:item.name}</a></li>
			{section-else}
				<li><a href={concat("/content/view/full/",$:item.node_id,"/")|ezurl} class="subnav2"><img src={"square_grey.gif"|ezimage} width="7" height="7" border="0" alt="NavigationSquare">{$:item.name}</a></li>
				{section show=$node_obj.path_array|contains($:item.node_id)}
				
				{/section}
			{/section}
			</ul>
		{/section}
		</li>
	{/section}
	{* END SECOND LEVEL *}
	{section name=closeulsec2 show=$:flag_section2|eq(1)}
		</ul><br />
	{/section}
	{* END FIRST LEVEL *}
	</li>
{/section}
	

Alex Jones

Friday 16 July 2004 10:00:34 am

Christian, I think you might be better served by using the Treemenu operator instead of the mutliple loops. The code you are using was the way to do it before the Treemenu operator was added.Check out http://ez.no/ez_publish/documentation/reference/template_operators/miscellaneous/treemenu for more information. The depth_skip attribute should help you do what you want.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

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 19:14:25
Script start
Timing: Jan 18 2025 19:14:25
Module start 'layout'
Timing: Jan 18 2025 19:14:25
Module start 'content'
Timing: Jan 18 2025 19:14:26
Module end 'content'
Timing: Jan 18 2025 19:14:26
Script end

Main resources:

Total runtime0.6509 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.0062 589.0391152.6250
Module start 'layout' 0.00620.0033 741.664139.4609
Module start 'content' 0.00950.6397 781.1250537.2109
Module end 'content' 0.64920.0017 1,318.335912.1563
Script end 0.6509  1,330.4922 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.5164160.0002
Check MTime0.00140.2105160.0001
Mysql Total
Database connection0.00100.156410.0010
Mysqli_queries0.608893.5328540.0113
Looping result0.00050.0802520.0000
Template Total0.613894.320.3069
Template load0.00220.331820.0011
Template processing0.611693.960820.3058
Template load and register function0.00020.028710.0002
states
state_id_array0.00110.171510.0011
state_identifier_array0.00150.237820.0008
Override
Cache load0.00160.2516100.0002
Sytem overhead
Fetch class attribute can translate value0.00070.102320.0003
Fetch class attribute name0.00090.132930.0003
XML
Image XML parsing0.00070.102320.0003
class_abstraction
Instantiating content class attribute0.00000.001230.0000
General
dbfile0.00090.1391160.0001
String conversion0.00000.001640.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
2content/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: 8
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs