Creating a basic RSS feed in Drupal
This tutorial shows how to create a news feed in Drupal that is offered on every page in your site.
To learn more about RSS and news feeds, check out the CoreDogs’ RSS lesson.
One feed to rule them
You create lots of feeds for a site. Feeds for forum entries, blog posts, pages, stories, ... It’s easy to confuse people.
With all of these options, what to do? People are used to seeing one feed for a site. Some sites offer more than one, and sophisticated users take advantage of them. But for most most people, having just one feed for a site is a good choice.
Drupal’s default feed
Dale McGladdery wrote a useful article on Drupal feeds. One of the things he explains is that Drupal has a default feed system. Just a little set up, and you’re off and running.
Log in as user 1 or someone else with administration rights. Go to Administration > Content management > RSS Publishing. You’ll see something like this:

Figure 1. RSS administration settings
The Feed content setting lets you choose what to show in each feed item. Your choices are:

Figure 2. Feed setting
I like to show the title and teaser. The title sometimes isn’t enough to let users know what an item is about. Including the entire content is usually overkill.
More on creating teasers later.
You need to know two important things about Drupal’s default feed:
- What the URL is.
- What items are added to the feed.
The default feed’s URL
The URL is /rss.xml. So the default feed for CoreDogs is http://coredogs.com/rss.xml. You don’t need to create it; it’s just there. Though you have to make sure users have easy access to it. More on this later.
Items in the default feed
What items are added to the default feed? Items that have their “Promoted to front page” setting turned on. Every node has this setting, and it’s either on or off.
Note: it doesn’t matter whether the node actually appears on the front page. In CoreDogs, all of the articles (like the one you’re reading now) have “Promoted to front page” set on. But none of them appear on the front page. Instead, CoreDogs has a custom front page.
So, how do you get “Promoted to front page” turned on? You need to know how to:
- Turn “Promoted to front page” on for existing nodes.
- Turn “Promoted to front page” on for new nodes.
Promoting existing nodes
For nodes that already exist, one approach is to edit each node, go down to the “Publishing options,” and check “Promoted to front page.” Then save.

Figure 3. Promoting a node
This can take a while if you have a lot of nodes. A quicker way is to go to Administer › Content management. Check the nodes you want to promote, choose “Promoted to front page” from the “Update options” list, and click the Update button.

Figure 4. Promoting many nodes at once
Promoting new nodes
For each content type you want listed in your feed, go to Administer › Content management, and click the “edit” link. Scroll down to the workflow settings. Check “Promoted to front page” under “Default options.” Now every new node of that type will have that setting turned on.
Check your feed
Go to /rss.xml on your site. You should see some items. W00f!
Teasers
Every Drupal node can have a teaser. A teaser is more of a psychological construct than a technical one.
We’re all pressed for time. And there are more pages on the Web than we could ever look at. So, how do we decide whether to spend precious time reading a particular page?
That’s what teasers are for. They’re short pieces of content that help readers decide whether to look at an entire page. Each teaser is attached to a particular node. One node, one teaser.
It’s easy for content authors to abuse teasers. For example, you can use scare tactics. If you write an article on, say, RSS feeds in Drupal, your teaser could be: “Poisonous gas cloud in your neighborhood!” That teaser has nothing to do with the article, but it will get you a few extra clicks. For a short time, anyway.
I advise against such deceptive tactics. Be honest in your teasers, and let readers decide what they want to do.
Go ahead and add teasers to items you want in your news feeds. An exception would be items that are very short, when the teasers would be as long as the content.
Here’s part of the page I’m working on now.

Figure 5. Adding a teaser
You can see the teaser in the top field. “Show summary in full view is checked, meaning that I’ve chosen to use the same content for the teaser and the first part of this article. I often don’t do that, however.
Showing feed icons
So, you’ve got some items in your feed. The items have teasers. They show up in /rss.xml. How do you actually expose the feed to your users?
Usually, you want a feed icon to appear. The standard icon is:

Figure 6. Standard RSS icon
Where do you put it? There are lots of options. For CoreDogs, I decided to have the icon appear on every page, in the standard browser location.
What the “the standard browser location” is varies from browser to browser. In Firefox and Safari, for example, the icon is in the address bar (that is, the place where you type the URL). In IE, the icon is just below the address bar.
How do browsers figure out whether to show the RSS icon for a page? They look in the page’s <head> area for something like this:
<link rel="alternate" type="application/rss+xml" title="CoreDogs" href="http://coredogs.com/rss.xml" />
How did I make this appear on every page on the site? I modified my theme. My theme is called nonzero_brown, and is stored in http://coredogs.com/sites/all/themes/nonzero_brown/.
I took some code from Dale McGladdery’s article, created the file template.php in my theme’s directory, and put this in it:
<?php
function nonzero_brown_preprocess(&$vars) {
drupal_add_feed(
url('rss.xml',
array('absolute' => TRUE)), 'CoreDogs'
);
$vars['head'] = drupal_get_html_head();
$vars['feed_icons'] = drupal_get_feeds();
}
Figure 7. Code to add an RSS icon to every page
W00f!
Now you know how to add a simple but effective news feed to your site!
Time to celebrate. Go play with your dog.




