If we want to set meta tags on a per page (controller-action) basis, we may use the?clientScript?application component.
Yii::app()->clientScript->registerMetaTag('This is an example', 'description'); $this->render('example'); } } ?>
This will insert the description meta tag automatically into the layout when the render() function gets called.
Another solution would be to use a parent controller with the property $pageDescription. That way we don't have to make a function-call to set the description. Instead, we can easily modify the description inside of the controller. In the layout-file we'll simply echo the meta tag (if defined).
pageDescription = 'This is an example'; $this->render('example'); } } ?>
pageDescription)) { echo '
Think about this:
$this->pageFeeds[] = 'http://example.com/feeds/recent.xml'; $this->pageFeeds[] = 'http://example.com/feeds/popular.xml';
I hope you enjoyed the read. Feel free to share your thoughts - thank you.
Tip:?Since the two classes?
ParentController
?and?ExtendedCController
?are no real controllers (they only function as parent-classes), you have to put them into the components folder (egprotected/components
).