You can try the following:
1) In 'components / Controller.php' :
public $metaDescription;
public $metaKeywords;
public function getMetaDescription() {
if(!$this->metaDescription)
return Yii::app()->settings->getValue('meta_description');
return $this->metaDescription;
}
public function getMetaKeywords() {
if(!$this->metaKeywords)
return Yii::app()->settings->getValue('meta_keywords');
return $this->metaKeywords;
}
2) In the layout of main.php :
...
Yii::app()->clientScript->registerMetaTag($this->getMetaDescription(), 'description');
Yii::app()->clientScript->registerMetaTag($this->getMetaKeywords(), 'keywords');
...
3) In other layouts :
...
$this->metaDescription = 'Your description here';
$this->metaKeywords = 'your, keywords, here';
...
Please note that Yii :: app () → settings-> getValue ('meta_description') and Yii :: app () → settings-> getValue ('meta_keywords') are my default values, which are taken from the database.
source
share