不同级别的用户在yii中有不同的界面布局


Different interface layout for different level users in yii

我是新来的。我正在开发一个系统与YII框架在PHP。我怎么能有不同的布局不同的模块?我希望模块A有接口A,模块B有接口B,但我知道的是,所有模块的接口登录都是一样的。谁能给我个火吗?

更新:

我找到了一种方法,那就是包括:

$this->layout = $layout;

在渲染页面之前在控制器内部的动作函数上进行操作。然而,我发现它并不是那么有效,因为我需要在每个动作中重复这句话。是否有一种方法可以在config/main.php页面上进行设置?可能在这部分:

'modules'=>array(
     'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'123',
        'generatorPaths' => array('bootstrap.gii'),
     ),          
     'admin',
     'consultant',
     'client',
),

您可以在config中为模块设置变量,如下所示:

'modules'=>array(
     'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'123',
        'generatorPaths' => array('bootstrap.gii'),
     ),          
     'admin' => array(
        'layout' => 'your_layout' //The layout for this module
     ),
     'consultant',
     'client',
),

这样你就可以为每个模块实现一个默认的布局。无需添加controller方法或变量。

更多信息请参见文档:这里和这里

try this:

class YourController extends Controller {
    public $layout = 'your_layout';
}