[font="Courier New"]$this->getId()[/font] gives you the controller name and [font="Courier New"]Yii::app()->defaultController[/font] the default controller name ("site" in the default setting)
[font="Courier New"]$this->getAction()->getId()[/font] gives you the action name and [font="Courier New"]$this->defaultAction[/font] the default action name of the current controller ("index" in the default setting)
So from here, you can compare both couples like this:
'visible'=>'(strcasecmp(basename($this->getId()), Yii::app()->defaultController) || strcasecmp($this->getAction()->getId(),$this->defaultAction))' /* returns false if home page ie "site/index" */
Credit: heavily inspired from this post when building a multilingual webapp
Works as I wanted. One more question, can I call functions in the visible for me to return true or false.
It is that if I put the conditions for all the controllers can appear where the menu items the expression of the item is too large. How can work like this:
You can put it in protected/layouts/main.php, or if you use that condition across other views, I guess you can put it in protected/components/Controller.php (it’s an extension of CController which all your webapp controllers extend from, in a standard configuration).
As a follow up to this concept, I wanted to have my menu’s visible but disabled. So the current page (be it admin, update, view…) is always disabled in the menu but the menu stays looking the same. ( I had a user request this…personally I don’t agree but trying to provide what is asked)