Home > Backend Development > PHP Tutorial > yii2 - 由views/page/xxx.php 来决定使用哪个layout

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:35:25
Original
1214 people have browsed it

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

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

<?php include("../layouts/main.php"); ?>报错

该怎么做呢?

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

解决方法:

<code>$this->context->layout='page';
</code>
Copy after login
Copy after login

回复内容:

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

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

<?php include("../layouts/main.php"); ?>报错

该怎么做呢?

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

解决方法:

<code>$this->context->layout='page';
</code>
Copy after login
Copy after login

<code>$this->content->layout = '@app/views/layouts/other.php';
</code>
Copy after login
Related labels:
Statement of this Website
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
Latest Issues
yii2 error connecting to mongodb3.2.4
From 1970-01-01 08:00:00
0
0
0
How to use mongodb to do rbac in yii2
From 1970-01-01 08:00:00
0
0
0
php - yii2-ueditor-widget
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template