menu item is not set active automatically...

I am using zii.widgets.CMenu

Problem is menu item is not set active automatically when the current request is triggered.

My Code in column2.php is as below.




 $this->widget('zii.widgets.CMenu', array(

				/*'type'=>'list',*/

				'activateItems'=>true,

				'encodeLabel'=>false,

				'items'=>

                                         array('label'=>'Inbox' , 'url'=>array('/message/inbox')),

                                         array('label'=>'Sent' , 'url'=>array('/message/sent')),

					))




Structure is as below

>Protected

>> modules

>>> message

>>>> controllers

>>>>> InboxController

>>>>> SentController

>> views

>>> message

>>>> inbox.php

>>>> Sent.php

>>Themes

>>> Theme1

>>>> views

>>>> layouts

>>>>> column2.php

So simply speaking when I click on Inbox, it does not actually become active… but it definitely redirects me to the right page and renders correctly but the link does not become active

I just have problem with the message menu , rest works fine… 6128

Screen Shot 2014-11-26 at 9.20.25 PM.png

I am not sure where I am wrong?

Please check:

http://www.yiiframework.com/forum/index.php/topic/59439-cmenu-isitemactive-does-not-check-for-actionid-without-controller/

I tried the snippet but it didn’t work actually

however the parameters are as follows


 $item=	Array ( [label] => Inbox 4 [url] => /boatapp/message/inbox )

$route= message/inbox/inbox

Ok, so you have an action inbox inside your controller inbox located in the message directory.

You have to write:


 	array('label'=>'Inbox' , 'url'=>array('/message/inbox/inbox')),

      array('label'=>'Sent' , 'url'=>array('/message/sent/sent')),

CMenu does not check the ‘defaultAction’ I suppose - another possible improvement for CMenu.

This didn’t work either


	array('label'=>'Inbox' , 'url'=>array('/message/inbox/inbox')),

      array('label'=>'Sent' , 'url'=>array('/message/sent/sent')),

[/code]

Now the parameters are as follows


Array ( [label] => Inbox 4 [url] => /boatapp/message/inbox/inbox )

message/inbox/inbox

if you can look at the controller structure, may be it has to do something with it. because for other "controllers" it works like a charm. Only the controller of the message is in the message module…

do you know if it has some effect? might be prefix is needed here

Already reported this as an issue

I’ld debug ‘CMenu’, check the parameters in:


!strcasecmp(trim($url,'/'),$route))

try to understand how the $url is built and why it is diferent from $route,

determine if the applicaiton is at fault or CMenu,

fix it.

No success yet


Item:>>> Array ( [label] => Inbox 4 [url] => Array ( [0] => /message/inbox ) )

Route:>>> message/inbox/inbox

Condition 1:>>> 1

Condition 2:>>> 1

Condition 3 route and url should be equal then its 1:>>> 

ok so I added this condition and now it works


if (Yii::app()->controller->uniqueID == trim($item['url'][0],'/'))

				$route=Yii::app()->controller->uniqueID;