[Solved] CMenu and URLs with parameters

Hi everyone,

I have the following URL rule:




'<year:\d{4}>/<controller:[A-Za-z]+>/<action:\w+>'=>'<controller>/<action>',



Now I’d like to create a menu item accordingly, something like this:




array('label' => Yii::t('election', 'Candidature'), 'url'=>array('/'.$year.'/candidate/register'))



Since the route is only ‘/candidate/register’ and therefore doesn’t match the URL ‘/2011/candidate/register’, the menu item is not rendered as active.

Does anybody know how to solve this? TIA for any hints!

– Andreas

Hi Andreas, welcome to the forum.

This is not the expected way of creating url.

What about this?




array('label' => Yii::t('election', 'Candidature'), 'url'=>array('candidate/register', 'year'=>$year))



That works, thanks a lot! :)

Best regards,

Andreas