开发者

Yii - modify response data

I need to dynamically generate title and meta tags in my ap开发者_JAVA百科plication. 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?


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.


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜