Home >PHP Framework >YII >How to set yii2 not to use layout

How to set yii2 not to use layout

王林
王林Original
2019-12-17 17:01:153072browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn