方法一:
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