How to use activateItems in CMenu

How to use activateItems in CMenu





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

    'items'=>array(

        // Important: you need to specify url as 'controller/action',

        // not just as 'controller' even if default acion is used.

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

        array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(

            array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),

            array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),

        )),

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

    ),

));









Any ideas?

http://www.yiiframework.com/doc/api/1.1/CMenu#activateItems-detail

some times ago there was a nice solution in this forum

i only have a modded version


function isItemActive($route, $id, $c = 0)

    {

        //explode the route ($route format example: /site/contact)

        $menu = explode("/", $route);


        //compare the first array element to the $id passed

        return $menu[$c] == $id ? true : false;

    }

here in the CMenu:


'items' => array(

                                                                        array('label' => Yii::t('header_menu', 'News'), 'url' => array('/Blog'), 'active' => isItemActive($this->route, 'Blog')),