How to create a layout that uses partial and footers

I have a red guide on views and layouts, I have googled how to do this, but I still can't get it to work. Here is the problem:

I want to have 2column.php and 3column.php layouts, where both use the _header.php and _footer.php particles.

Layout example 2columns.php:

render _header.php $content and some other extra code render _footer.php 

Whatever I do, I cannot get it to work. Can someone please email me a real simple example of how to achieve this? thanks

Please note that the answer is:

using:

 <?php $this->beginContent('@app/views/layouts/header.php'); ?> <!-- You may need to put some content here --> <?php $this->endContent(); ?> 

doesn’t help me ... I don’t know what to do with it, I can’t get him to do what I need.

+5
source share
2 answers

You should just try:

 <?php $this->beginPage() ?> <?= $this->render('@app/views/layouts/header', $_params_) ?> <!-- main content --> <?= $this->render('@app/views/layouts/footer', $_params_) ?> <?php $this->endPage() ?> 

And don't forget to use the following in the title view:

 <head> <?= Html::csrfMetaTags() ?> <?php $this->head() ?> ... </head> 

More details:

+5
source

You can use the following to render the header and footer:

 echo \Yii::$app->view->renderFile('@app/views/layouts/footer.php'); 
0
source

All Articles