Można spróbować to:
1) 'components/Controller.php':
public $metaDescription;
public $metaKeywords;
public function getMetaDescription() {
if(!$this->metaDescription)
return Yii::app()->settings->getValue('meta_description'); //return default description
return $this->metaDescription;
}
public function getMetaKeywords() {
if(!$this->metaKeywords)
return Yii::app()->settings->getValue('meta_keywords'); //return default keywords
return $this->metaKeywords;
}
2) w układzie main.php:
...
Yii::app()->clientScript->registerMetaTag($this->getMetaDescription(), 'description');
Yii::app()->clientScript->registerMetaTag($this->getMetaKeywords(), 'keywords');
...
3) W twoich innych układów:
...
// If you don't do that, the description and keywords will be default for this page.
$this->metaDescription = 'Your description here';
$this->metaKeywords = 'your, keywords, here';
...
nocie, że Yii :: app() -> Ustawienia-> getValue ('meta_description') oraz Yii :: app() -> Ustawienia-> getValue ("meta_keywords") to moje domyślne wartości, które bierze od DB.
Mam już metatag opisu; chcę zastąpić treść opisu; –
Moja odpowiedź powyżej to zrobi. Użycie id pozwoli ci nadpisać istniejący opis. – Alex
Testowałem i już to nie działa; propozycje? –