我已经创建了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' => '#'),
)
)
);
答案 0 :(得分:0)
也许使用内联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' => '#'),
)
)
);