I have a custom module that uses it's own set of layout/views. However for the errors I want to use the default site layout and view. In my module I'm setting the errorHandler
errorAction
to site/error
class AdminModule extends CWebModule {
public function init() {
$this->setImport(array(
'admin.models.*',
'admin.components.*',
));
Yii::app()->setComponents(array(
'errorHandler'=>array('errorAction'=>'site/error'),
));
$this->layout = 'admin';
}
public function beforeControllerAction($controller, $action) {
if(parent::beforeControllerAction($controller, $action)) {
$controller->layout = $this->layout;
return true;
} else {
return false;
}
}
}
However it's still using the admin layout and I want it to use the default layout. How do I overwrite it just for the error action?
In your actionError()
of SiteController
Just add the default layout name
class SiteController extends Controller
{
public function actionError()
{
$this->layout='defaultLayoutName';
//rest of the code goes here
}
}