根据布局名称更改菜单

时间:2013-08-30 14:01:13

标签: php yii widget

我希望能够根据给定的布局添加菜单。例如,如下所示?,如果当前布局是/ entry

,[条目背景]变得可见
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
    array('label'=>'Entries', 'url'=>array('/entry'),'authItemName'=>'SuperUser','visible'=>Yii::app()->user->checkAccess('SuperUser')),
    array('label'=>'Entries Background', 'url'=>array('/entry/more'),'authItemName'=>'SuperUser','visible'=>$this->layout = '/entry'),
),)); ?>

感谢

1 个答案:

答案 0 :(得分:0)

也许你可以试试这个:

<?php $this->widget('zii.widgets.CMenu',array(
    'items'=>array(
        array('label'=>'Entries', 'url'=>array('/entry'),'authItemName'=>'SuperUser','visible'=>Yii::app()->user->checkAccess('SuperUser')),
        array('label'=>'Entries Background', 'url'=>array('/entry/more'),'authItemName'=>'SuperUser','visible'=>$this->layout == '//layouts/entry'),
),)); ?>

我改变了你的状况:

'visible'=>$this->layout = '/entry'

到此:

'visible'=>$this->layout == '//layouts/entry'