Entity view (Content)

Drupal Theming RSS Feed Views

By jtsang
Jun. 5, 2009

A lot of RSS feeds are very plain and boring, which sometimes results to unsubscriptions or plain out ignoring your feed. Drupal web designers should spend some time to make these more readable and more useful to bring in more traffic.

A few reasons why we should include images in RSS feeds is that it draws in users and also gives a visual representation of content. Think of it as a blog landing page. Another reason is that a few sites use aggregators that pull your RSS feeds so that will lead to more traffic.

I had this problem for the longest time of theming and adding images to a RSS feed View. I always got the default feed of just the title and some teaser text. It was too plain, no dates, and no images even when I added fields to the view. Googling for sample code and solutions was not much of any help, so here my purposed solution for all you readers!

1. Install Modules
Modules you need:
Views: http://drupal.org/project/views
Contemplate: http://drupal.org/project/contemplate
Imagecache: http://drupal.org/project/imagecache


2. Create your RSS Feed view
Your content type should have an image field that you will use to be displayed in your RSS feed.


3. Create your imagecache preset for your RSS feed.
Don't make it too large as many feed readers are small.


4. Configure contemplate template settings
Navigate to Content management > Content templates or /admin/content/templates


5. Open Content Templates
For the content types that you want to theme click on edit template.


6. Edit Template
Open the RSS fieldset
Check box "Affect RSS output"
Theme your node output for your RSS feed. Under RSS Variables you can see all the variables you have access to and here is where you would include the imagecache theming.


7. Final Touches
Now any time the node type is used in a RSS feed it will be themed. You can even write a switch statement or if statement if you need to theme it differently on different RSS feeds using arg[0] too.


Final result examples could look like:




Post Tags: