Page 1 of 1

Left navigation menu - show children of a specific parent

Posted: Mon Nov 07, 2011 11:27 am
by kzub
Hi! I'm totally new to CMSMS and smarty, but I tryed to create my own navigation menu. It is a list of items of three levels. Initially it shows only items of the firt level, but when I click on an item which has children I want to open the sub-menu with all childrens. I want to style the submenus with different colors, so I need them in a separate list.
My problem is that when I open an item which has childrens I get all items of level two in my submenu :( I'm obviously missing a condition!
I will appreciate any suggestions. Thank you!

Here is the code of my menu:

Code: Select all

{if $count > 0}
<__script__ type="text/javascript" language="javascript" 
src="lib/helparea.js"></__script>

<ul style="padding-left:0;">
{foreach from=$nodelist item=node}
{if $node->depth == 1}

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

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

{if $node->haschildren == true && $node->current == true}
<ul style="padding-left:15px;">

{foreach from=$nodelist item=node}
{if $node->depth > 1}
<li>
<a href="{if $node->id == 15}/{else}{$node->url}{/if}"{if $node->target ne ""} target="{$node->target}"{/if} style="background: #bbb;">{$node->menutext}</a>
</li>
{/if}
{/foreach}
</ul>

{/if}

{if $node->current == true && $node->depth > 1}

<ul style="padding-left:15px;">

{foreach from=$nodelist item=node}
{if $node->depth > 1}
<li class="expanded">
<a href="{if $node->id == 15}/{else}{$node->url}{/if}"{if $node->target 

ne ""} target="{$node->target}"{/if} style="background: #bbb;">{$node->menutext}</a>
</li>
{/if}
{/foreach}
</ul>

{/if}

{/foreach}
</ul>
{/if}
 

Re: Left navigation menu - show children of a specific paren

Posted: Mon Nov 07, 2011 7:14 pm
by mcDavid
from the help page:
collapse="1" - Turn on (set to 1) to have the menu hide items not related to the current selected page.


If I understand your problem right, this is what you need to set in the {menu} tag.

Re: Left navigation menu - show children of a specific paren

Posted: Mon Nov 07, 2011 8:18 pm
by kzub
Brilliant!!! It works! Thank you soooo much.

Re: Left navigation menu - show children of a specific paren

Posted: Fri Dec 02, 2011 3:00 am
by Dr.CSS
It helps to read the Help and all of the default content pages as they have lots of how to use info...

P.S. See link in signature if you don't have access to default content...