方法一:
yii模块默认使用系统当前的主题布局文件,若是在主配置文件中配置了主题好比:php
访问index.php?r=admin/default/index时,默认使用了protected/views/layout /main.php,若是想使用模块本身的layout文件(protected/modules/admin/views/layout /main.php),须要修改protected/modules/admin/controllers /DefaultController.php,在这个文件内添加下面代码:app
public $layout = 'application.modules.admin.views.layouts.main'; yii
或者布局
public $layout = '/layouts/column2';this
方法三:
在模块入口文件 beforeControllerAction中添加处理代码,这个方法发生于动做执行前:(例如AdminModule.php)
public function beforeControllerAction($controller, $action)
{
$controller->layout = 'application.modules.admin.views.layouts.book';
if(parent::beforeControllerAction($controller, $action))
{
// this method is called before any module controller action is performed
// you may place customized code here
return true;
}
else
return false;
}spa