YiiBooster TbMenu, динамически добавляющий активный класс

Я создал Yii Bootstrap TbMenu. Как я могу динамически добавить активный класс?

$this->widget('bootstrap.widgets.TbMenu',
    array(
        'type' => 'list',
        'items' => array(
            array(
                'label' => 'Home',
                'url' => '#',
                'itemOptions' => array('class' => 'active')
            ),
            array('label' => 'Library', 'url' => '#'),
            array('label' => 'Applications', 'url' => '#'),
        )
    )
);

person Arash K    schedule 21.09.2013    source источник


Ответы (1)


Может быть, со встроенным if?

$this->widget('bootstrap.widgets.TbMenu',
array(
    'type' => 'list',
    'items' => array(
        array(
            'label' => 'Home',
            'url' => '#',
            'itemOptions' => (($isActive) ? array('class' => 'active') : array())
        ),
        array('label' => 'Library', 'url' => '#'),
        array('label' => 'Applications', 'url' => '#'),
    )
)

);

person Frildoren    schedule 21.09.2013