Forums / Developer / Sticky navigation

Sticky navigation

Author Message

David Jones

Monday 02 October 2006 2:32:33 am

I've got some sub navigation on my site that extends to 2 levels.

I've coded this into my pagelayout.tpl like so.

<ul>
{foreach $pagelayout_node.children as $child}
	<li><a href={$child.url_alias|ezurl}>{$child.name}</a>
		<ul>
			{foreach $child.children as $child_subnav}
			<li><a href="{$child_subnav.url_alias|ezurl}}">{$child_subnav.name}</a></li>
		       {/foreach}
		</ul>
        </li>
{/foreach}
</ul>

This works fine. However, when I click on a child node I lose the top level. I would like this to still be display.

Let's see if i can explain this a little. My navigation is something like below:

1
-- 1.1
-- 1.2
2
- 2.1
- 2.2
3
4
- 4.1

When I click 1.1 the top level all disappears on the page. So I can't go back up the tree. I would like the navigation tree to remain constant independant of the level i am on.

Did that make any sense?

Marco Zinn

Monday 02 October 2006 9:12:18 am

Eh... yes, it makes sense.
I guess, $pagelayout_node contains the current node, so you will only display the current node's children with your code.
You should probably use a hard-coded node (Node 2, for example), if you want to have a "static" menu.

But: Why don't you use the provided menus or the treemenu code/template?

Marco
http://www.hyperroad-design.com

David Jones

Monday 09 October 2006 4:55:47 am

Thanks Marco,

But could you be a little more spcific?

How could I use the Tree code template?

Thanks

David Jones

Monday 09 October 2006 5:35:55 am

OK, I found some code in the documentation that seems to claim to do what I want however, when I put it in pagelayout.tpl it doesn't output anything.

{def $mainMenu=treemenu( $module_result.path, $module_result.node_id ) }
{foreach $mainMenu as $menu}

{$menu.level} - {$menu.text}<br />
{/foreach}
{undef $mainMenu}

Any idea what I'm missing?