Link activos del menu principal

I have recently started using yii framework and my main problem is not how to stop the link from the main menu when you try to active dynamic pages ie views that communicate with their controllers Any ideas to solve this problem?5960

Selección_002.png

Hi pedrox, welcome to the forum.

With which are you working, Yii 1.1.x or 2.0?

And could you try to state your problem once again?

with 1.1.x

I can not get is that the link stay active in the menu dynamically

[color="#556B2F"]/* Moved from "Miscellaneous" to "General Discussion for Yii 1.1.x" */[/color]

You can access the controller instance from the layout view (usually "views/layout/main.php") using "$this".

For instance, this is showing the breadcrumbs that is defined dynamically in the controller.




  <?php $this->widget('zii.widgets.CBreadcrumbs', array(

    'links'=>$this->breadcrumbs,

  )); ?><!-- breadcrumbs -->



So the main menu can also be controlled dynamically by some controller property.




  <div id="mainmenu">

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

      'items'=>array(

        array('label'=>'Home', 'url'=>array('post/index')),

        array('label'=>'Something', 'url'=>array('someController/someAction'), 'visible'=>$this->something), // this is it

        array('label'=>'About', 'url'=>array('site/page', 'view'=>'about')),

        array('label'=>'Contact', 'url'=>array('site/contact')),

        array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),

        array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('site/logout'), 'visible'=>!Yii::app()->user->isGuest)

      ),

    )); ?>

  </div><!-- mainmenu -->