Yii Framework Forum

No endbody and endPage after calling render


(jammi ) #1

Hi guys,
I try to add registerMetaTag in my controller but it doesn’t appear in my view.

Here is my code

    \Yii::$app->view->registerMetaTag([
    'name'      => 'description',
    'content'   => Yii::t('seo', '__desc_home'),
]);

My view

<?= $this->render('_head');?>
<?php echo $content;?>
<?= $this->render('_footer');?>

My _head.php

<?php
use \yii\helpers\Html;
?>

<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language; ?>">
<head>
<?php $this->head() ?>

</head>

<body>
<?php $this->beginBody() ?>

My _footer.php

<?php
use \yii\helpers\Html;
?>

<script src="/vendor/jquery-3.1.1.min.js"></script>
<script src="/vendor/jquery.touchSwipe.min.js"></script>
<script src="/js/bundle.js"></script>

<?php $this->endBody(); ?>
</body>
<?php $this->endPage() ?>
</html>

After rendering

<! DOCTYPE html>
<html lang="en-UK">
<head>
    **<![CDATA[YII-BLOCK-HEAD]]>**

I guess there is a problem of calling endbody() and endpage().
They are not in the same file. Does anybody has a tip?

thx!!


(Alirz23) #2

I think the reason your tags are not being included is because you are calling $this->beginPage() in one context and $this->endPage() in a different context same goes for $this->beginBody(), $this->endBody()

quick question are your assets loading fine?


(jammi ) #3

Hi alirz23,

thanks for your answer. The assets are also not loading fine.
Isn’t it possible to put beginBody and endBoday in different files?


(Alirz23) #4

no it would not work make sure the both end+begin calls are in the same file