public function beforeAction($action) { if (parent::beforeAction($action)) { if ($action->id == 'error' && Yii::$app->user->isGuest) { $this->layout = 'main-login'; } return true; } else { return false; } }