Left navigation menu - show children of a specific parent

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
kzub
New Member
New Member
Posts: 3
Joined: Mon Nov 07, 2011 11:20 am

Left navigation menu - show children of a specific parent

Post 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}
 
mcDavid
Power Poster
Power Poster
Posts: 377
Joined: Tue Mar 31, 2009 8:45 pm

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

Post 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.
kzub
New Member
New Member
Posts: 3
Joined: Mon Nov 07, 2011 11:20 am

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

Post by kzub »

Brilliant!!! It works! Thank you soooo much.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post 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...
Post Reply

Return to “CMSMS Core”