assign class to a specific menu item

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
pimhd
Forum Members
Forum Members
Posts: 19
Joined: Mon Aug 28, 2006 12:47 pm

assign class to a specific menu item

Post by pimhd »

I would like to assign a class to the link of a specific menu item (the contact page).

I've tried to use the Extra Page Attribute for this and call it from the menu manager but i can get this only to work for the current page. Not for any other item in the menu.

So when I'm on the homepage, I want the contact page link tot look something like this

Code: Select all

<a href="contact" class="fancybox">Contact</a>
Does anyone how to achieve this?
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: assign class to a specific menu item

Post by Wishbone »

Post your menu manager code where you're using Extra1.. We can probably figure it out.
pimhd
Forum Members
Forum Members
Posts: 19
Joined: Mon Aug 28, 2006 12:47 pm

Re: assign class to a specific menu item

Post by pimhd »

I solved it in another way which does it for me.

I used the simple_navigation menu in menu manager and added the lines

Code: Select all

{elseif $node->menutext =='Contact' }
<li><a class="fancybox" href="{$node->url}"><span>{$node->menutext}</span></a>
Ugly programming so if anyone knows a betters solution, Let me know.
lordanthony
New Member
New Member
Posts: 4
Joined: Tue Jan 15, 2008 12:01 pm

Re: assign class to a specific menu item

Post by lordanthony »

I add a class to each <li> in menumanager :

Code: Select all

menu{$node->index}
You can then define styles for each node eg

Code: Select all

li.menu1{background-color:#000;
User avatar
kidcardboard
Forum Members
Forum Members
Posts: 54
Joined: Mon Sep 28, 2009 5:25 pm

Re: assign class to a specific menu item

Post by kidcardboard »

in the menu manager template you can put the following:

Code: Select all

<a href="{$node->url}"{if $node->extra1 != ''} class="{$node->extra1}"{/if}>{$node->menutext}</a>
and then on the page under Extra 1 just put whatever class you want applied to that menu node.

You could also do:

Code: Select all

<a href="{$node->url}" id="{$node->alias}">{$node->menutext}</a>
to give that node a unique id, which might work a little better if you need to just target that single element.
Post Reply

Return to “CMSMS Core”