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.