Needing help using treemenu

Author Message

Christoph Polus

Monday 27 June 2005 9:11:20 am

Hello

I've got some problems understanding the TreeMenu function.

I have a navigation that looks like this:

Page 1
- Sub1.1
- Sub1.2
Page 2
- Sub2.1
- Sub2.2

What I would like to achieve now is an output like this:

<a href="URL" id="ID">LINKTEXT(Page1)</a>
<a href="URL" id="ID">LINKTEXT(Page2)</a>
<br/>

[somewhere else in the site]

<div id="PARENT_ID(ID of Page1)
  <a href="URL" id="ID">LINKTEXT(Page1.1)</a>
  <a href="URL" id="ID">LINKTEXT(Page1.2)</a>
</div>

<div id="PARENT_ID(ID of Page2)
  <a href="URL" id="ID">LINKTEXT(Page2.1)</a>
  <a href="URL" id="ID">LINKTEXT(Page2.2)</a>
</div>

The divs are set to visible on mouseover the pages on top level. So when I hover with my mouse on Page 1, the DIV with the children of page 1 should appear. Now this works statically. But I'd like to implement this into the TreeMenu.

Now I don't know how I can loop through all the level 2 objects, sort them by parent and priority and get their parent id once to put it into the encapsulating DIV as reference. Does anybody have an idea?

Thanks
Chris

Christoph Polus

Tuesday 28 June 2005 7:50:02 am

Hi

I'm almost there. This is what I have for now:

{let topMenus=treemenu($module_result.path, 2, true() , 0, 0)}
	<div id="leftNavigation">
		{section name=topMenu loop=$topMenus max=3}
			{section show=$topMenu:item.is_selected}
				<a id="navItem{$topMenu:item.id}" onmouseover="clearTimeout(timer); showDiv('navItem{$topMenu:item.id}', 'subNavLayer{$topMenu:item.id}');" onmouseout="timer=setTimeout('hideDiv({$topMenu:item.id})', pause);" href={$topMenu:item.url_alias|ezurl}>{$topMenu:item.text}</a>
			{section-else}
				<a id="navItem{$topMenu:item.id}" onmouseover="clearTimeout(timer); showDiv('navItem{$topMenu:item.id}', 'subNavLayer{$topMenu:item.id}');" onmouseout="timer=setTimeout('hideDiv({$topMenu:item.id})', pause);" href={$topMenu:item.url_alias|ezurl}>{$topMenu:item.text}</a>
			{/section}
		{/section}
	</div>
		{section name=topMenu loop=$topMenus max=3}
			<div style="left: 502px; top: 226px; visibility: hidden;" id="subNavLayer{$topMenu:item.id}">
				[What to put here?]
			</div>
		{/section}
{/let}

Now I only need to find out how I can iterate through all the children objects to output the subobjects.

Thanks for any help.
Chris

Christoph Polus

Tuesday 15 November 2005 2:18:46 am

Hey,

I did this a long time ago but wanted to share my findings with other people who need assistance in understanding the TreeMenu for the first time.

Here you are.

{let topMenus=treemenu($module_result.path, 2, true() , 0, 0)}
	<div id="leftNavigation">
		{section name=topMenu loop=$topMenus max=3}
			{section show=eq( $module_result.path[1].node_id, $topMenu:item.id )}
				<a id="navItem{$topMenu:number}" onmouseover="clearTimeout(timer); showDiv('navItem{$topMenu:number}', 'subNavLayer{$topMenu:number}');" onmouseout="timer=setTimeout('hideDiv({$topMenu:number})', pause);" href={$topMenu:item.url_alias|ezurl}>{$topMenu:item.text}</a>
			{section-else}
				<a id="navItem{$topMenu:number}" onmouseover="clearTimeout(timer); showDiv('navItem{$topMenu:number}', 'subNavLayer{$topMenu:number}');" onmouseout="timer=setTimeout('hideDiv({$topMenu:number})', pause);" href={$topMenu:item.url_alias|ezurl}>{$topMenu:item.text}</a>
			{/section}
		{/section}
	</div>
	{section name=topMenu loop=$topMenus max=2}
		<div id="subNavLayer{$topMenu:number}" class="subNavLayer" style="left: 502px; top: 226px; visibility: hidden;" onmouseover="clearTimeout(timer);" onmouseout="timer=setTimeout('hideAllDiv()', pause);">
		{def $dhtmlMenus=fetch( 'content', 'list', hash('parent_node_id', $topMenu:item.id, 'sort_by', array( array( 'priority' ) ) ) )}
		{foreach $dhtmlMenus as $dhtmlMenu}
			<a class="subNav" href={$dhtmlMenu.url_alias|ezurl}>{$dhtmlMenu.name}</a>
			{delimiter}<div class="subNavLine">&nbsp;</div>{/delimiter}
		{/foreach}
		</div>
	{/section}				
{/let}

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 31 2025 00:40:15
Script start
Timing: Jan 31 2025 00:40:15
Module start 'layout'
Timing: Jan 31 2025 00:40:15
Module start 'content'
Timing: Jan 31 2025 00:40:15
Module end 'content'
Timing: Jan 31 2025 00:40:15
Script end

Main resources:

Total runtime0.0226 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0044 588.1328151.2109
Module start 'layout' 0.00440.0037 739.3438220.6875
Module start 'content' 0.00820.0130 960.03131,001.8047
Module end 'content' 0.02110.0014 1,961.835933.9922
Script end 0.0225  1,995.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002611.6895140.0002
Check MTime0.00114.8487140.0001
Mysql Total
Database connection0.00062.614210.0006
Mysqli_queries0.00219.421230.0007
Looping result0.00000.048510.0000
Template Total0.00104.410.0010
Template load0.00073.011710.0007
Template processing0.00031.349810.0003
Override
Cache load0.00052.128010.0005
General
dbfile0.00146.332580.0002
String conversion0.00000.032740.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs