Question

I need to dynamically generate title and meta tags in my application. So I need to get response object (f.e. like in symfony framework) and set corresponding data in section. How can I do this in Yii?

Was it helpful?

Solution

To modify page title, set CController::pageTitle either in your action or your view.

$this->pageTitle = '...';

As long as your main layout echoes this inbetween title tags, it works very well. (This is done by default.)

To add other headers, use

Yii::app()->clientScript->registerMetaTag($content, $name, $httpEquiv, $options);

Please refer to the API for explanation of this signature.

OTHER TIPS

Probably this is a long overdue question but for the sake of future visitors, there's a nice wiki article on exactly this: http://www.yiiframework.com/wiki/54/simplified-meta-tags/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top