Customize RSS Feeds generated by Views2 in Drupal 6

January 15, 2010 - 02:12

The Views module in Drupal provides a Feed display that will allow for site owners to publish the content on their sites as RSS feeds. However, unlike a page or block display, the feed display does not allow for addition of custom tags inside the feed using the Views administration UI. There is however a way to add custom tags, attributes and values into the generated feed using hook_nodeapi.

Hook_nodeapi supports an 'rss item' operation which gets called whenever an item is inserted into the feed during the generation of a feed. The corresponding nodeapi call can be used by modules to insert custom tags to the feed.

For example, by inserting the following 'rss item' case to the nodeapi hook in a module

    case 'rss item':
      $custom_tags = some_function_call();
      $rss_items = array();
      $rss_items[] = array(
        'key' => 'key_name',
        'attributes' => array(
          'attribute1_name' => $attribute1_value,
          'attribute2_name' => $attribute2_value,
        'value' => $key_value,
    return $rss_items;

you will be able to insert a tag

<key_name attribute1_name="attribute1_value" attribute2_name="attribute2_value">key_value</key_name>

For the 'rss item' nodeapi hook the function should return an array of items that are to be inserted corresponding to each node in the feed. Each item in the array should be an array of one key, zero or more attributes and optionally a value.

For more complex capabilities you will have to use the Feeds module instead of the default core feed functionality.

Get Drupal updates straight to your inbox

To prevent automated spam submissions leave this field empty.

Post your comments / questions

For more complex capabilities we will have to use the Feeds module instead of the default core feed functionality is illustrated well in the article....

Yes, You are right about the Feeds module but if the only requirement is to add custom tags to nodes in feeds then the core feed should work fine too.

Anoop John

'value' => $key_value;
should be
'value' => $key_value,


Thanks for the correction. I have duly made changes.

Anoop John

Wow! Thank you! I always wanted to write in my site something like that. Can I take part of your post to my blog?