specific class for menu item

Hello everybody!

I would like to get any tips and hints on the next question: I need to set some class for hyperlink when the site user is on this page.

For example:

page = contacts.html

menu item = <li><a href="/contacts.html">Contacts</a></li>

I want to get such link <li><a class="accent" href="/contacts.html">contacts</a></li>

Following code =

array('label'=>'Contacts', 'url'=>array('/site/contacts'),

'accent' => Yii::app()->controller->getId() == 'contacts')

returns the code =

<li class="active"><a href="/contacts.html">Contacts</a></li>

i.e. the class will be set to LI tag… and this class named ACTIVE

What do I need to do?

help me please!

You have to override CMenu.renderMenuItem() method.

But why? If you want to apply some special CSS rules, then you can write:

li.active a { color: red; }

I don’t see a reason to change this behavior.

P.S. You can change li’s class by specifying CMenu.activeCssClass.

to andy_s,

thanks for your quick answer… I have got exhaustive explanation

at that moment I am using such CSS solution = #menu_top ul li.active a{color:white;}

but I was wondering to learn - how to avoid this? i.e. where to find the native framework solution?