I have red the guide about views and layouts, I have googled how to to this, but I still can not make it work. Here is the problem:
I want to have 2column.php and 3column.php layouts, where both are using _header.php and _footer.php partials.
2columns.php layout example:
render _header.php
$content and some other extra code
render _footer.php
Whatever I do I can not make it work. Can someone please post me real simple example of how to achieve this ? Thanks
Please note that answer:
use:
<?php $this->beginContent('@app/views/layouts/header.php'); ?>
<!-- You may need to put some content here -->
<?php $this->endContent(); ?>
does not help me... don't know what to do with it, I cant make it do what I need.
Partial designs are a unique or particular portion of a full product design. Often, they are part of a product that cannot be separated, sold, or used independently.
You should simply 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 your header view :
<head>
<?= Html::csrfMetaTags() ?>
<?php $this->head() ?>
...
</head>
Read more :
render()
: http://www.yiiframework.com/doc-2.0/yii-base-view.html#render()-detail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With