Reputation: 154
I am doing a project in Yii framework now. i am concern about title tag and other meta tag which will be dynamic as well for SEO propose , The data for the tags will be fetched from database and displayed in the front-end.
What Should me my approach ?
Upvotes: 2
Views: 1848
Reputation: 2656
You have basically two options here:
CController
, create a title
property like @PeterM suggested and then inherit your controllers from this controller. Upvotes: 2
Reputation:
In controller define:
public $title;
Then in your layout echo
it into title tag.
<title><?= $this->title; ?></title>
In any action just assign $title
and it will be displayed in layout title tag.
public function actionView()
{
$this->title = 'My title fetched from DB'
}
Upvotes: 1