Sachy
(Sachin Mandalia)
November 26, 2014, 8:21pm
1
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
I am not sure where I am wrong?
le_top
(Ext Yiiframework Com)
November 26, 2014, 9:20pm
2
Sachy
(Sachin Mandalia)
November 26, 2014, 10:12pm
3
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
le_top
(Ext Yiiframework Com)
November 26, 2014, 10:23pm
4
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.
Sachy
(Sachin Mandalia)
November 26, 2014, 10:38pm
5
le_top:
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
le_top
(Ext Yiiframework Com)
November 26, 2014, 11:22pm
6
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.
Sachy
(Sachin Mandalia)
November 27, 2014, 12:09pm
7
le_top:
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;