Different Feeds for different 'Features': Where to implement?

I want to create RSS Feeds with Yii for my website(s). I read this wiki page about creating feeds: http://www.yiiframework.com/wiki/20/how-to-generate-web-feed-for-an-application and some other tips/posts about this topic.

But all of those approaches are assuming that a web site is using one feed only which is not necessarily bound to the models which are displayed/managed at the same time. I would like to create different feed: One for guestbook comments if the user is on the guestbook site, another for latest photos if he is on the photos site and so on.

Following my intuition, I would consider this a new action in the model’s controller. For example a “feed” action in the CommentController (for the guestbook).

The design problem in this case is that actually the controller is already bound to a HTML layout template with the $layout variable, which does not make sense with Feeds.

From a system design point of view, where and how you would implement this? Creating a new Controller managing all feeds or implementing the feed action in the model’s controller? And using Zend_* stuff to generate the feed or using view files just as outputting HTML as well?

Thanks for your ideas and input,



You can place wherever you want the action of the feed, if you don’t need the template at all you can use


it renders only the view, or in alternative you can prepare a template for rss with the header of the feed, and set with:

public function actionRss()


   $this->template= 'rss';



Thanks for the reply.

I assume you mean $this->layout instead of $this->template?

Anyway, I know that this is possible. I would like to know your opinions, where would you implement it? As an own controller or in the model’s controller? And why?

It depends.

If is a rss, for example, of cars, I’d put in the car controller. In this case you already have an actionList, the action rss does nearly the same, just without paging and in rss form.

If a global rss wich shows all news in the site, you can place in site controller.

And, of corse, I mean $this->layout… sorry for mistake