输入banner图图片脚本导航/分类

yii2-由views/page/xxx.php来决定使用哪个layout

想法如下:
有时候我觉得用views中的参数来决定用哪个layout
这样子该怎么做呢?

frontend/views/page/xxx.php
$this->layout='main'; 报错

报错

该怎么做呢?

由view倒置决定使用哪个layout怎么做到?

解决方法:

$this->context->layout='page';

回复内容:

想法如下:
有时候我觉得用views中的参数来决定用哪个layout
这样子该怎么做呢?

frontend/views/page/xxx.php
$this->layout='main'; 报错

报错

该怎么做呢?

由view倒置决定使用哪个layout怎么做到?

解决方法:

$this->context->layout='page';

$this->content->layout = '@app/views/layouts/other.php';