CMenu, pages, clean URLs, and active items

Hi all,

I’ve scoured the Yii forums for an answer to this question:

How to get CMenu (and CNormalizeUrl in general) to turn


into a URL that looks like this:

and NOT like this:

I’ve tried declaring the CMenu URL like this:


which works in terms of pulling up the page, but then CMenu does not recognize it as the active URL.

It’s a mystery to me why CNormalizeUrl sometimes adds the _GET parameters in clean URL format, and sometimes adds them in traditional _GET parameter format.

Can anyone help?

BTW, this thread looked like it was going to address the issue, but it didn’t:


Thanks in advance.

For me it seems like it’s a url management problem.

Have you defined the good urls rules in your config file?

You can check how to define it here:

Yes. I’ve modified the rules to accommodate this:







This seems to work fine. But how do you get CNormalizeUrl to generate the link in that format? In my menu, I have:

array('label'=>'menuItemName', 'url'=>array('site/page','view'=>'pageName')),

But this generates [b]



instead of [b]



This isn’t the way it behaves if I use

array('label'=>'menuItemName', 'url'=>array('event/view','id'=>'event_id')),

which generates




Also, in a separate but related issue, the auto-generated active link styles are only appearing at the top level of my CMenu items.

If I input them like this:

array('label'=>'News', 'url'=>array('news/index')),

it highlights the link when I go to that page, but not when I go to the page’s children. I suspect that might be because of the /index in the routing.

But if I input it like this:

array('label'=>'News', 'url'=>array('news')),

it assumes ‘news’ should be tacked on to the current controller (which varies depending on where the menu is displayed).

And if I input it like this:

array('label'=>'News', 'url'=>array('/news')),

or this:

array('label'=>'News', 'url'=>'news'),

or this:

array('label'=>'News', 'url'=>'/news'),

it doesn’t highlight at all.

I have activateItems and activateParents set to true. I’m perplexed how one is supposed to make the parents recognize their children.

I think the 4th rule is somewhat broken.

And, even if it were written correctly, it won’t work for your purpose, because array(‘site/page’,‘view’=>‘pageName’)) will fall into the 3rd rule before it reaches 4th.

Would you please try the following?






// or ...