Forums / Developer / tree menu with hidden first level

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>

eZ debug

Timing: Jan 18 2025 16:02:08
Script start
Timing: Jan 18 2025 16:02:08
Module start 'content'
Timing: Jan 18 2025 16:02:09
Module end 'content'
Timing: Jan 18 2025 16:02:09
Script end

Main resources:

Total runtime0.8092 sec
Peak memory usage4,096.0000 KB
Database Queries191

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 587.7344180.8281
Module start 'content' 0.00680.6972 768.5625542.2891
Module end 'content' 0.70390.1051 1,310.8516336.7422
Script end 0.8091  1,647.5938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4668210.0002
Check MTime0.00140.1745210.0001
Mysql Total
Database connection0.00090.112210.0009
Mysqli_queries0.751792.90461910.0039
Looping result0.00160.19741890.0000
Template Total0.785297.020.3926
Template load0.00180.218220.0009
Template processing0.783596.825620.3917
Template load and register function0.00010.014210.0001
states
state_id_array0.00070.089510.0007
state_identifier_array0.00120.147920.0006
Override
Cache load0.00130.1658100.0001
Sytem overhead
Fetch class attribute can translate value0.00090.116630.0003
Fetch class attribute name0.00080.097630.0003
XML
Image XML parsing0.00080.100430.0003
class_abstraction
Instantiating content class attribute0.00000.000730.0000
General
dbfile0.00250.3085270.0001
String conversion0.00000.000730.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
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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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