Drupal 6 RSS Omnibus

Drupal RSS functionality is spread out, and so is information on it. After first accumulating mental notes, which turned into a collection of written notes and code snippets, I realized there's a lot to be said on the topic. A single overview covering all things RSS seemed like a useful idea. This is a starting point covering many things RSS. I invite you to leave a comment if you have anything to add, a great reference or blog post, or if I've gotten something wrong.

"Out of the box" RSS

  • RSS is configured and controlled at Administration > Content management > RSS Publishing
    RSS Publishing Settings
  • The default RSS URL is rss.xml (e.g. www.example.com/rss.xml)
  • The default RSS feed selects content using the same selection criteria as the /node path ("/node" is the default front page setting). It contains the content of any node that's both "Published" and "Promoted to front page".
    Publishing Settings

    The exact content and number of nodes is determined by the RSS settings.
  • There is no provision to theme a node's RSS output in the PHPTemplate theme engine. Your node.tpl.php file is ignored when the feed content is rendered.
  • Because of the above point, double check the RSS feed output of any feed containing nodes you've created or modified with CCK.
  • Every taxonomy term automatically gets a feed (whether you want it or not)
  • The is no provision in the Drupal base installation (core) to publish comments in a RSS feed. A contributed module (RSS Comments or Views) is required. More on this later on.
  • The RSS feed will only be published on the front page. More on this later.


  • Any theming of your CCK node done in the node.tpl.php will not be reflected in the RSS feed output.
  • You can control which CCK fields are displayed in the RSS feed:
    Publishing Settings

    Since you can't control the output via a .tpl.php file, adjusting the settings here can sometimes provide a workable solution.
  • Some kind of programmatic solution is required if you need further control of the output. At time of writing the only options known to the author were the Contemplate module (Appnovations has a writeup here: Drupal Theming RSS Feed Views) and writing your own hook_nodeapi function.

RSS and Views

  • Views can create RSS feeds, both as part of an existing view and as a dedicated RSS view. This means you can create a RSS feed for nearly anything.
  • Robert Safuto of Awakened Voice has a good video on this: Configuring Views To Generate RSS
  • Views can override your default feed. This might be desirable if you aren't using "Promote to front page" as your RSS publishing criteria.

RSS and Comments

RSS Feed Publishing for Module Programmers

  • hook_nodeapi() has a $op case for RSS:
    "rss item": An RSS feed is generated. The module can return properties to be added to the RSS item generated for this node. See comment_nodeapi() and upload_nodeapi() for examples. The $node passed can also be modified to add or remove contents to the feed item.
  • You can add a feed (RSS meta link) to the document <head> with the drupal_add_feed() function.
  • A convenient method using drupal_add_feed() is placing it in your module's hook_init() function.
    function mymodule_init() {
    drupal_add_feed(url('myrsspage'), t('My feed title');

    You can find a better example in the Comment RSS module (Via CVS: commentrss.module).
  • Drupal also provides a set of functions for creating RSS feeds. Having never used these functions I'm not in a position to talk about them.

Publishing RSS Feed Availability for Browsers and Others

  • Feeds are communicated to browsers (and others) through a <link> tag in the HTML document <head>:
    <link rel="alternate" type="application/rss+xml" title="Group 42 RSS" href="http://www.group42.ca/rss.xml" />
  • The <link> tags give the browser the information to produce the RSS information. Multiple RSS link entries are allowed:
    Firefox RSS IconIE RSS Icon
  • The <head> tag contents are contained in the $head variable, output from page.tpl.php
      <?php print $head; ?>
      <title><?php print $head_title; ?></title>
      [ … ]
  • $head is initially generated by the template_preprocess_page() function with drupal_get_html_head() function and it automatically includes all added feeds:
    $variables['head'] = drupal_get_html_head();

RSS and Theming

  • Drupal has a collection of functions for adding and displaying feeds. These are:
    drupal_get_feeds() (Used to produce $feed_icons variable)
  • The following code can be added to your template preprocess function to publish your site feed on every page of your website:
    // Place the site's RSS feed on every page
    drupal_add_feed(url('rss.xml', array('absolute' => TRUE)), 'Digital Doodles RSS');
    $vars['head'] = drupal_get_html_head();   // Refresh $head variable
    $vars['feed_icons'] = drupal_get_feeds();  // Refresh $feed_icons variable
  • The theme_feed_icon function is a convenient way to insure all of your feed icons are consistantly themed and provide a single point to change the look of the feed icon if this is required.

A note about drupal_add_feed

The feed URL is used to uniquely identify the feed. This is handy for avoiding duplications, but only if you always use the same form of the URL to represent a feed. Take the example of adding rss.xml to the HEAD of every page. Drupal uses the absolute form of the URL: http://www.example.com/rss.xml. If you use drupal_add_feed with the relative form of the URL, "/rss.xml", you'll get two feed entries for the same feed. You'll notice in the example above that the URL function is used to create an absolute URL before calling drupal_add_feed.

Pulling Content from External RSS Feeds

There's a rich set of options for this. Start with the aggregator module, which is part of Drupal core. If this doesn't meet your needs, and it won't if you have a moderately sophisticated use case, check out the discussion at RSS & Aggregation Group. This is a rapidly evolving area.


This is bookmarked. Valuable reference for the RSS stuff in Drupal. Thx!

Graet wrap-up for "Drupal and RSS". Thanks for your effort doing this! Allready bookmarked :)

Thanks. I managed to add my custom views based RSS feed via drupal_add_feed in template.php. But how to disable the Drupal default RSS feed at rss.xml? Or override it when not using promote parameter, as you mention. Thanks

While searching drupal forums for a solution to disable RSS Feed, it looks like people been asking for this ability since 2005.

An enable/disable check box in the Modules > Core - optional would suffice to most users who do not need this feature.

Thanks 1,000 times over for such a logically compiled and presented summary of something that is simple yet hard to research on drupal.org ;-)

You might add that contemplate has some RSS theming where you can add any namespace to the feed using the drupal format_xml function

For anyone looking to disable or set permissions on RSS feeds, there's now a module for that: http://drupal.org/project/rss_permissions

RSS in Drupal has always been one of those neglected areas with little info or appropriate hooks for alteration. This summary you have provided is excellent. Here are a few links, some you have already mentioned, including a link to the MediaRSS module...

Drupal Feed information and extra modules
http://drupal.org/project/rss_permissions (provides some control over site and taxonomy feeds)

Media RSS
http://drupal.org/project/mediarss (through views)

That module is useless to me. Yes, once there is NO permission to access the feed, the feed is still there and empty. I want to kill the link, the icon and the file as well.

Great post, well structured, especially for those new to drupal. I've noticed above this line: "Views can override your default feed.", but I can't find information on how to do this without additional modules. Thanks for any pointers...

I haven't tried it myself, but I believe if you create a Views RSS feed with the url of rss.xml, it will override the default RSS feed.

Thanks for the suggestion. I thought I've tried that before and it didn't work, but I will try once more to be sure.

I've tried it again, it does not work. Tried rss.xml /rss.xml (not accepted) and ../rss.xml. Unfortunately none of them worked. Any other suggestions?

Amazing! Thank you so much for writing this all up. It was a lifesaver. :)