Drupal has taken RSS integration to heart, providing feeds for every category, every view, forum containers—just about every list of any kind has an associated RSS feed.
Power users may appreciate this granularity but I find the multitude of feeds confusing. When a user clicks an RSS icon on a view—one they perhaps arrived at via a Google search—do they understand that they are subscribing to just that view and not the full site? I'm not convinced.
For this site I want to expose only the main feed, the one corresponding to the front page. Feeds for the article categories, tags, views, and anything else should be replaced with the main feed.
Feed information shows up in two places. The first is in the HTML header, where Drupal adds this bit of markup magic:
<link rel="alternate"
type="application/rss+xml"
title="RSS - Software Development"
href="/taxonomy/term/50/0/feed" />
This element tells the browser that the page has an associated RSS feed. The browser uses this to display a subscription widget, like this one in Firefox.

The second place the feed shows up is at the bottom of the page, where Drupal adds this little orange icon:
![]()
You'll Need a Theme
In order to make this happen, I need to catch one of Drupal's theme functions. In order to do that I'll need a custom theme where I can put it. Setting up a custom theme is easy, and enables all kinds of styling and tweaking possibilities. If you don't have one already, you should. If you do, you can skip ahead to the next section.
To start a custom theme, create a new folder under sites/all/themes (you might need to create this folder). Let's call ours something imaginative, like "piglatin". Feel free to substitute in your own clever idea.
In this new folder, create a ".info" file with the same name: piglatin.info. Paste in this code, and replace the pig latin.
name = Pig Latin description = Site specific tweaks and stylings. core = 6.x base theme = garland stylesheets[screen,projection][] = piglatin.css
Change the base theme if you want; specify the name of the folder which contains the theme. The stylesheet is optional but useful. It will appear after all of the other stylesheets, so you'll have final say on how things are styled. You'll have to create this file of course, in your theme folder.
For more information on creating themes, see the Drupal 6 Theme Guide over on drupal.org.
Preprocessing the Page
Now let's get to work. In your theme folder, create the file template.php if you don't have one already, and paste in the function below. If this file already exists, look to see if it has this function, and paste it in if not. And swap in your theme name in place of "piglatin".
function piglatin_preprocess_page(&$vars) {
}
Clear your caches to make this change take effect (Site Configuration > Performance > Clear cached data).
This hook is called just before the page is built, and provides an opportunity to add or change the values that get sent to the page template. You can read more about it here if you're interested.
Fixing the Header
For the header element, I need to swap out the feed title and the URL and replace them with the values for our main feed. Unfortunately, the theme hook is not called until after Drupal has munged the header together into the a big hunk of HTML, so its not a simple as setting new values.
This bit of code will scan the header looking for an RSS element and pull out the title and URL attributes. Not every page has a feed, hence the conditional.
function piglatin_preprocess_page(&$vars) {
if (preg_match(
'/\<link rel="alternate" type="application\/rss\+xml" title="(.*?)" href="http://industriousone.com/%28.%2A?%29="/',
$vars['head'], $matches)) {
// found an RSS link element
}
}
Replace the attributes with the main feed title and URL.
function piglatin_preprocess_page(&$vars) {
if (preg_match(
'/\<link rel="alternate" type="application\/rss\+xml" title="(.*?)" href="http://industriousone.com/%28.%2A?%29="/',
$vars['head'], $matches)) {
$vars['head'] = str_replace($matches[1],
variable_get('site_name', 'Drupal'),
$vars['head']);
$vars['head'] = str_replace($matches[2],
url('rss.xml'),
$vars['head']);
}
}
That does it for the header. Using the browser controls, create a new subcription from any RSS enabled page on the site and you will receive the main feed.
Fixing the Footer
That leaves the icon at the bottom of the page, which can be modified using the feed_icons variable. The highlighted code attaches the main feed to the icon.
function piglatin_preprocess_page(&$vars) {
if (preg_match(
'/\<link rel="alternate" type="application\/rss\+xml" title="(.*?)" href="http://industriousone.com/%28.%2A?%29="/',
$vars['head'], $matches)) {
$vars['head'] = str_replace($matches[1],
variable_get('site_name', 'Drupal'),
$vars['head']);
$vars['head'] = str_replace($matches[2],
url('rss.xml'),
$vars['head']);
$vars['feed_icons'] = theme_feed_icon($feed_url, 'Subscribe');
}
}
I opted to turn the icon off entirely.
$vars['feed_icons'] = NULL;
Bonus Points: Exceptions
There's an exception to my "one feed" rule: the forums. This extra conditional skips my code for the forum RSS feeds.
function piglatin_preprocess_page(&$vars) {
if (preg_match(
'/\<link rel="alternate" type="application\/rss\+xml" title="(.*?)" href="http://industriousone.com/%28.%2A?%29="/',
$variables['head'], $matches)) {
if (strpos($matches[2], '/forums/') !== 0) {
$vars['head'] = str_replace($matches[1],
variable_get('site_name', 'Drupal'),
$vars['head']);
$vars['head'] = str_replace($matches[2],
url('rss.xml'),
$vars['head']);
}
}
}
That's It!
That's everything you need to take control over your Drupal RSS feeds. I may update this article from time to time as I learn more, or to reflect changes in Drupal.
09-Aug-2009: Rewrote to use the preprocess page hook introduced in Drupal 6.x.

hi too feel that it is a bit confusing but at the same time it definitely the best thing we got. drupal has takes the RSS feeds in the right manner and we should spend time and benefit from it. have good commannd on the RSS feed and see how you enjoy the work.