문제

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
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top