S
S
Sergey Kuznetsov2016-11-07 22:51:02
Yii
Sergey Kuznetsov, 2016-11-07 22:51:02

Is it possible to use nested templates inside views in Yii2?

The Russian-language documentation only states that nested templates are used inside templates.

Sometimes you need to nest one template within another.
Using the approach above, you can nest templates in multiple levels.

In fact, you can use this connection method in views - it works.
<?php
// Файл вида @app/views/design/index.php
/* @var $this yii\web\View */
?>

TEST: begin<br>

<?php $this->beginContent('@app/views/design/file.php') ?>
It's content!
<?php $this->endContent() ?>

TEST: end<br>

I know about yii\web\View::render() and other ways of connecting a view inside another view, but this particular moment was of interest.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2016-11-07
@webinar

What for? There are blocks www.yiiframework.com/doc-2.0/yii-widgets-block.html
There are widgets.

D
Dmitry, 2016-11-08
@slo_nik

Goodnight.
Of course you can. Use one main template, customize your menus in plug-ins.
For example, splitting the template for different rbac access levels. There is one menu for the admin, another for the moderator, and you leave the general code in the main template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question