MetaTags In Yii Framework 1.0

In yii framework 1.0, Registers a meta tag that will be inserted in the head section (right before the title element) of the display page. Each call of this method will cause a rendering of new meta tag like keywords, description, robots etc, even if their attributes are equal.


public CClientScript registerMetaTag(string $content, string $name=NULL, string $httpEquiv=NULL, array $options=array (
), string $id=NULL)
$content string content attribute of the meta tag
$name string name attribute of the meta tag. If null, the attribute will not be generated
$httpEquiv string http-equiv attribute of the meta tag. If null, the attribute will not be generated
$options array other options in name-value pairs (e.g. ‘scheme’, ‘lang’)
$id string Optional id of the meta tag to avoid duplicates
{return} CClientScript the CClientScript object itself (to support method chaining, available since version 1.1.5).


Yii::app()->clientScript->registerMetaTag('Keyword1, keyword2', 'keywords');
<meta name="keywords" content="Keyword1, keyword2" />


Yii::app()->clientScript->registerMetaTag('Site Description Details', 'description');
<meta name="description" content="Site Description Details" />


Yii::app()->clientScript->registerMetaTag('text/html;charset=UTF-8', null, 'content-type');
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
Yii::app()->clientScript->registerMetaTag('userid=xyz; expires=Wednesday, 08-Aug-15 23:59:59 GMT;', null, 'cookie');
<meta http-equiv="cookie" content="userid=xyz; expires=Wednesday, 08-Aug-15 23:59:59 GMT;" />


Yii::app()->clientScript->registerMetaTag('NOINDEX, NOFOLLOW', 'ROBOTS');
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
Yii::app()->clientScript->registerMetaTag('INDEX, NOFOLLOW', 'ROBOTS');
<meta name="ROBOTS" content="INDEX, NOFOLLOW" />		
Yii::app()->clientScript->registerMetaTag('NOINDEX, FOLLOW', 'ROBOTS');
<meta name="ROBOTS" content="INDEX, NOFOLLOW" />		


Yii::app()->clientScript->registerMetaTag('max-age=0', null, 'cache-control');
<meta http-equiv="cache-control" content="max-age=0" />
Yii::app()->clientScript->registerMetaTag('no-cache', null, 'cache-control');
<meta http-equiv="cache-control" content="no-cache" />


Yii::app()->clientScript->registerMetaTag('0', null, 'expires');
<meta http-equiv="expires" content="0" />
Yii::app()->clientScript->registerMetaTag('Mon, 16 June 2014 23:59:59 GMT', null, 'expires');
<meta http-equiv="expires" content="Mon, 16 June 2014 23:59:59 GMT" />


Yii::app()->clientScript->registerMetaTag('no-cache', null, 'pragma');
<meta http-equiv="pragma" content="no-cache" />


Yii::app()->clientScript->registerMetaTag('Author Name', 'author');
<meta name="author" content="Author Name" />


Yii::app()->clientScript->registerMetaTag('30', null, 'refresh');
<meta http-equiv="refresh" content="30" />
Yii::app()->clientScript->registerMetaTag('30', null, 'refresh',array('url'=>''));
<meta http-equiv="refresh" content="30" url=""  />

Custom MetaTag

Yii::app()->clientScript->registerMetaTag('637502, 637503', 'zipcode');
<meta name="zipcode" content="637502, 637503" />

Yii 1.0 name-value pairs of meta tag.

Yii::app()->clientScript->registerMetaTag(null, null, null,array('charset'=>'utf-8'));
<meta charset="utf-8"/>