我在yii项目中有自定义菜单链接,我想在菜单上应用选定的类。
<li><a href="<?php echo $serverPath.CController::createUrl('user/index'); ?>" Dashboard</a></li>
请提出任何建议,我对CActive Menu有一点了解,但对类型菜单不了解。
答案 0 :(得分:0)
在所有菜单上使用此功能。我解决了一些问题。
<li <?php if(Yii::app()->controller->id == 'any-controllery-nmae' && Yii::app()->controller->action->id == 'any-function'){echo 'class="active"';} else { echo '';} ?>>
<a href="<?php echo $serverPath.CController::createUrl('any-controllery-nmae/any-function'); ?>" title="Dashboard">Dashboard</a></li>
</li>
<li <?php if(Yii::app()->controller->id == 'any-controllery-nmae' && Yii::app()->controller->action->id == 'any-function'){echo 'class="active"';} else { echo '';} ?>>
<a href="<?php echo $serverPath.CController::createUrl('any-controllery-nmae/any-function'); ?>" title="Dashboard">Dashboard</a></li>
</li>
<li <?php if(Yii::app()->controller->id == 'any-controllery-nmae' && Yii::app()->controller->action->id == 'any-function'){echo 'class="active"';} else { echo '';} ?>>
<a href="<?php echo $serverPath.CController::createUrl('any-controllery-nmae/any-function'); ?>" title="Dashboard">Dashboard</a></li>
</li>