Cmenu - Class "active" Not Being Assigned

Hi folks,

I have started to develop a website using the default Yii webapp as the template.

It’s all going fine but I have come to this problem…

I tried to clean up the URLs and have done so successfully. However, when I change the CMenu URL link from this format…



to this…



Everything works fine except the active class is not assigned. I should probably mention here that I have moved away from SiteContoller to individual controllers for the index, about, contact etc.

Anything I can do to rememdy this?

Thanks in advance.

Hi U4EA,

In a case page URL isn’t the same as CMenu link URL (like in your case), you may reform link URL or use property ‘active’.

As it is said in CMenu documentation,


 array('label' => 'Settings', 'url' => array('/admin/settings'), 'active' => ($this->id === 'settings')),

Thank you very much :)

One thing that kinda leads on from this…

If I do not specifiy a page i.e. I just use the URL route of, it does not assign the class to the ‘index’ menu item. Is there a way I can fix this to use route incoming requests with no specified controller to the index controller?

Dear U4EA

I hope the following is helpful in this scenario.

array('label'=>$this->id==="site"?"Home":"List", 'url'=>array('index'),'active'=>($this->action->id==="index")),


Works perfectly. Thank you!

Just noticed an issue with that. When I go to then it sets both the url=>index and url=>about to active. Any ideas?

in your view files add this code

echo $this->action->id

tell us what is the output in both cases

Dear U4EA

This is what document on CMenu says.

What we are doing is something tricky.

In my suggestion, obviously we have to ensure that we should not have two items with same action(index).

Someone may suggest a better workaround.


For the root ( and the other classes, it is ‘index’.


echo $this->action->id;

produces ‘site’ for the root, then the expected ‘index’ for the home page, ‘about’ for about etc.

Hi folks,

I modified it to the following, which seems to be working fine…

'active' => ($this->id==="site" || $this->id==="index")

Thanks for the help guys! :)

Just as an after thought, I would imagine it would also be a perfectly acceptable solution to configure the front loader to have ‘index’ as the default controller by adding this to $config…


Works for for me and I can’t see any drawbacks to it?