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 be my approach ?
Thanks in advance
Page 1 of 1
Dynamic Meta Tag
#2
Posted Yesterday, 01:38 AM
You may declare meta tags as main Controller properties and to set their values, for example at beforeRender() method.
Example:
Layout
Controller
For title there's a yii pageTitle. You may overwrite getPageTitle() with your own implementation.
Example:
Layout
<meta name="keywords" content="<?php echo CHtml::encode($this->keywords)?>" />
<meta name="description" content="<?php echo $this->description?>" />
Controller
/**
* @var string meta tag keywords content
*/
public $keywords = '';
/**
* @var string meta tag description content
*/
public $description = '';
/**
* This method is invoked at the beginning of {@link render()}.
* @param string $view the view to be rendered
* @return boolean whether the view should be rendered.
*/
protected function beforeRender($view)
{
list($keyword, $description) = Yii::app()->seoHelper->findMetaTags();
$this->keywords = $keyword ? $keyword : Yii::app()->settings->get('meta', 'keywords');
$this->description = $description ? $description : Yii::app()->settings->get('meta', 'description');
return parent::beforeRender($view);
}
For title there's a yii pageTitle. You may overwrite getPageTitle() with your own implementation.
#3
Posted Yesterday, 01:40 AM
I think you should creat new database table , and get this table to front-end .
Creat a table :
Seo
-META tag:
--meta title
--meta des
--meta tag
--meta robots
--meta property ( important for seo richsnippest)
...
-REL tag
rel="author"
rel="publiasher"
rel="canonical"
...
And then , use same code get in Yii !
Creat a table :
Seo
-META tag:
--meta title
--meta des
--meta tag
--meta robots
--meta property ( important for seo richsnippest)
...
-REL tag
rel="author"
rel="publiasher"
rel="canonical"
...
And then , use same code get in Yii !
Share this topic:
Page 1 of 1

Help













