Home >PHP Framework >YII >How to set yii2 not to use layout
The method to set up not using layout in yii2:
Member variables within the controller
public $layout = false; //不使用布局 public $layout = "main"; //设置使用的布局文件
Inside the controller member method
$this->layout = false; //不使用布局 $this->layout = "main"; //设置使用的布局文件
Select layout in view
$this->context->layout = false; //不使用布局 $this->context->layout = 'main'; //设置使用的布局文件
Recommended related articles and tutorials: yii tutorial
The above is the detailed content of How to set yii2 not to use layout. For more information, please follow other related articles on the PHP Chinese website!