Page 1 of 1

[solved]simple menu query?

Posted: Thu May 21, 2009 7:33 pm
by macko
duuuhhhhhh i feel silly now as this was easy to do.   i spent all day yesterday trying to figure this out but i couldn't see the wood for the tree menu....

Hi All,

I have a query regarding menus. 
My site has the main nav at the top of the page.  At the side of the page is the sub nav - all good. 

However I want to add children to the sub nav pages and only have these items appear in the menu if the sub nav items are clicked.

Right now when I add a child to my sub menu items this child also appears in the sub menu.  Is there a way to stop the menu showing children of pages until that particular page is clicked?

ie:  sub menu first appears 

sub menu
item 1
item 2
item 3

then when item 2 is clicked I want menu to become...


sub menu
item 1
item 2
   child of item 2
   child of item 2
   child of item 2
item 3

and so on.

I have {menu template='cssmenu.tpl' start_level='2' collapse='1'} in my template.

Many thanks,
Ronan

Re: [solved]simple menu query?

Posted: Sat Oct 17, 2009 5:08 pm
by docman
Hi, I see this topic has gotten outdated, though it would deserve attention. My attempt is the same, so I hope someone may be able to help us with.

Re: [solved]simple menu query?

Posted: Sat Oct 17, 2009 5:47 pm
by Jos
For one site I have this menu-template, which you can call just with {menu} when you make this new template default in menu-manager.

Note: it only works if you have pages in two levels.

Code: Select all

{if $count > 0}
<ul class="clearfix">
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}

{if $node->current == true}
<li class="currentpage"><a href="{$node->url}" class="currentpage"{if $node->target ne ""} target="{$node->target}"{/if}> {$node->menutext} </a>

{elseif $node->parent == true && $node->depth == 1 and $node->type != 'sectionheader' and $node->type != 'separator'}
<li class="activeparent"> <a href="{$node->url}" class="activeparent"{if $node->target ne ""} target="{$node->target}"{/if}> {$node->menutext} </a>

{elseif $node->type == 'sectionheader'}
<li class="sectionheader">{$node->menutext}

{elseif $node->type == 'separator'}
<li style="list-style-type: none;"> <hr class="separator" />

{else}
<li><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}> {$node->menutext} </a>

{/if}

{/foreach}

{repeat string="</li></ul>" times=$node->depth-1}</li>
</ul>
{/if}

Re: [solved]simple menu query?

Posted: Sat Nov 07, 2009 11:29 pm
by Dr.CSS
The answer was in the post...

I have {menu template='cssmenu.tpl' start_level='2' collapse='1'} in my template....

You can use whatever menu template you want...