Adding the feed links
Now that we have created our feed and altered the URL structure to make it more user and search engine friendly, we need to add the ability for users to subscribe to the feed. One way to do this is to add the following code before rendering the pages in which we want to add the RSS feed link. Let's do this for both the project listing page as well as a specific project details page. We'll start with the project listings page. This page is rendered by the ProjectController::actionIndex() method. Alter that method as such:
public function actionIndex() { $dataProvider=new CActiveDataProvider('Project'); Yii::app()->clientScript->registerLinkTag( 'alternate', 'application/rss+xml', $this->createUrl('comment/feed')); $this->render('index',array( 'dataProvider'=>$dataProvider, )); }
The above highlighted code adds the following to the <head> tag of the rendered HTML:
<link rel="alternate" type="application/rss+xml" href="/commentfeed...