Introduction

In Yii, the $this->layout property is used to define which layout file should be applied to a view. By default, Yii uses @app/views/layouts/main.php as the layout, but you can dynamically change it within controllers or actions.

Changing Layout in a Controller  

To set a layout for an entire controller, assign a value to $this->layout inside the controller class:

Changing Layout in an Action

To apply a different layout for a specific action, set $this->layout inside the action method:

Disabling Layout

If you want to disable the layout for a specific action, set $this->layout = false;

 

 

 

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *