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

    'name'      => 'description',
    'content'   => Yii::t('seo', '__desc_home'),

My view

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

My _head.php

use \yii\helpers\Html;

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


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

My _footer.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(); ?>
<?php $this->endPage() ?>

After rendering

<! DOCTYPE html>
<html lang="en-UK">

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


(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