Navigator, how to give class depending on depth

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
CMSmsmsms
New Member
New Member
Posts: 2
Joined: Thu May 04, 2017 11:38 am

Navigator, how to give class depending on depth

Post by CMSmsmsms »

Hello everyone

I am struggling with the Navigator a bit. What my template needs is to give the 'outer' ul a certain class (nav navbar-nav) and the ul inside it so to say (for the dropdown) another class (dropdown-menu). I understand this is quite trivial and have been searching for an hour in de CMSMS docs but I was unable to find the answer.

Would be great if you could give a hint

I am using CMSMS 2.16 and the 'simple' menu template that came with it.

Thanks!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3484
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Navigator, how to give class depending on depth

Post by velden »

Code: Select all

{function name=Nav_menu depth=1}{strip}
<ul class="{if $depth==0}nav navbar-nav{else}dropdown-menu{/if}">
  {foreach $data as $node}
    {* setup classes for the anchor and list item *}
...
I recently worked on a BS3 menu and it needed more checks. But this should do what you asked.
CMSmsmsms
New Member
New Member
Posts: 2
Joined: Thu May 04, 2017 11:38 am

Re: Navigator, how to give class depending on depth

Post by CMSmsmsms »

Velden, That works! Thanks so much!
Post Reply

Return to “CMSMS Core”