我正在开发一个 Yii 项目,在菜单中,我想在访问特定项目时将菜单项设置为动态激活......我无法理解如何为静态页面执行此操作。这是我的代码:
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('/site/index'),'active'=>(Yii::app()->controller->id=='site' && Yii::app()->controller->action->id=='index')),
array('label'=>'About Us', 'url'=>array('/site/page', 'view'=>'about')), //HOW SHOULD I KNOW WHEN SHOULD THIS GET ACTIVE
array('label'=>'News', 'url'=>array('/news/index'),'active'=>Yii::app()->controller->id=='news'),
array('label'=>'Gallery', 'url'=>array('/images/index'), 'active'=>Yii::app()->controller->id=='images'),
array('label'=>'Calendar', 'url'=>array('/calendar/index'), 'active'=>Yii::app()->controller->id=='calendar'),
array('label'=>'Contact Us', 'url'=>array('/site/contact'), 'active'=>(Yii::app()->controller->id=='site' && Yii::app()->controller->action->id=='contact')),
),
)); ?>