CMenu activeCssClass doesn't seem to be working.

i read in the documentation that the CMenu widget automatically assigns a class=“active” to a currently active item. when i view the selection’s source, i don’t see any class=“active” in any of my menu items. i think it’s not working or something. i need this to set a background image for an active link via css. i already have .active ul li{color:#F00;} in my css file but it doesn’t show anyhow. pls help… thank you

recheck your css file. i think you don’t have that structure of active element.




.active ul li{color:#F00;}



well for starters, it is documented that CMenu assigns the ‘active’ class on an li.

and i do have that kind of structure…

Hi Kael.

Cmenu assigns authomatically only if the path is the same of the url property.

If, for example, you have the url set to array(‘controllerId’) and the page called is controllerId/index, CMenu will not assign this property.

For make it work, there is the property ‘active’.

You can set:




   'url'=>'user'

   'active'=>$this->uniqueId=='user'



Like that the link will be active for all actions of the controller userController (uniqueId is the indentificator of the controller).

For debug, I advice you to choose an item in the menu and write:




   'active'=>true



so you can easily check your css. After it you can try to make it dynamic

hi Zac! thank you very much!!! pretty much the answer i needed. :D