In the controller, I want to change the layout from main to error. For this I write
$this->layout='error'; return $this->render('deny'); But still looking for the file deny.php in main. Why does not it switch to error?
To change the layout, it is sufficient to define the property $layout in the controller.
Example:
class PostController extends Controller { public $layout = 'post'; // ... } Changing the layout does not mean that the directory containing the controller's view-elements will be changed. In order to change the directory in which the controller's view-elements will be contained, it is necessary to define the $viewPath property inside the controller (similar to the example above) or call the setViewPath() method in the body of one of the controller's actions.
viewPath in the controller. - withoutnameSource: https://ru.stackoverflow.com/questions/624538/
All Articles