fix meta tags

parent ff092d07
......@@ -34,9 +34,9 @@ class PageController extends \common\components\BaseController
}
$content = $model->content->content;
$this->meta_title = $model->metaTags->title . ' - ' . \Yii::$app->params['name'];
$this->meta_description = $model->metaTags->description;
$this->meta_keywords = $model->metaTags->keywords;
$this->meta_title = $model->metaTag->title . ' - ' . \Yii::$app->params['name'];
$this->meta_description = $model->metaTag->description;
$this->meta_keywords = $model->metaTag->keywords;
return $this->render('view', ['content'=>$content]);
}
......
......@@ -106,6 +106,19 @@ class CoContent extends \common\components\ActiveRecordModel
return $query;
}
/**
* @return \yii\db\ActiveQuery
*/
public function getMetaTag($lang_id = null)
{
$lang_id = ($lang_id === null)? Languages::getCurrent()->id: $lang_id;
return $this->hasOne(MetaTags::className(), ['object_id' => 'id'])->where([
'model_id' => get_class($this),
'lang_id' => $lang_id
]);
}
/**
* @return \yii\db\ActiveQuery
*/
......
......@@ -100,9 +100,9 @@ class SiteController extends BaseController
$model = \common\modules\content\models\CoContent::findOne(['url' => 'site/error']);
$content = $model->content->content;
$this->meta_title = $model->metaTags->title . ' - ' . \Yii::$app->params['name'];
$this->meta_description = $model->metaTags->description;
$this->meta_keywords = $model->metaTags->keywords;
$this->meta_title = $model->metaTag->title . ' - ' . \Yii::$app->params['name'];
$this->meta_description = $model->metaTag->description;
$this->meta_keywords = $model->metaTag->keywords;
return $this->render('error', ['content'=>$content]);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment