i'm trying to render meta tag on page header by use: In my View:
<?php
$this->registerMetaTag(['name' => 'keywords', 'content' => 'yii, framework, php']);
?>
and in my layout i put this code in head tag position:
<?php $this->head()?>
But it does not working. Anyone who have the same problem, can help me solve this problem. Thank you !!
To define a meta tag through the registerMetaTag method, use the following code in your controller:
public function actionIndex()
{
\Yii::$app->view->registerMetaTag([
'name' => 'description',
'content' => 'Description of the page...'
]);
return $this->render('index');
}
and this markup in the layout:
<head>
<?php $this->head() ?>
</head>
I've updated the basic demo application (from http://www.yiiframework.com/download/) that you can download here - https://www.dropbox.com/s/9rarzhtw65e5zo1/basic.zip?dl=0 and see this approach in action.
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