Skip to main content

custom RSS fields in Drupal

If you like to create a custom RSS feed in Drupal, it is pretty simple. You just need to load the Views module and make sure that you have a content type that you want to have a feed for.

From there, creating the RSS feed is pretty simple… in fact, you can even use that feed to work with Feedburner for tracking without any custom module for Feedburner if you don’t want.
 
In fact, one way that you can use this is you want to create an xml site map for Google Webmaster tools that doesn’t include pages you don’t want indexed (such as forms or no-follow pages). I’ll let you figure out how to adapt this for that purpose.
 
Here are the steps:
 
  1. Make sure that you have a content type that you want an RSS feed for. The most common type is a blog, but you can have it for any content type like a newsletter or tutorial.
     
  2. You’ll need to go to the views module admin page (example.com/admin/build/views).
     
  3. You can add a new view or edit an existing view. I’ll show you how to add a new view. You’ll want to click on the “Add” tab at the top of the page.


     
  4. Give the view a name and description and select “Node” for the View type. Then click the next button at the bottom of the page.


     
  5. On the next screen you can change the defaults or just add a new RSS view. If you are going to use this same view to create a page or a block, I would recommend that you change the defaults as much as possible.

    First, you’ll want to add an RSS display like this:



    Change the pull down menu from page to feed and click “add display”.
     
  6. Make sure that you have the feed selected on the left and you’ll want to edit the following areas by clicking on the blue link next to my arrows (my description of these is below the screen shot). Make sure you hit update at the bottom of each option.



    +Name: This will only appear in the admin window, but I recommend you change it so that it is more descriptive.



    +Title: This is the name that will appear at the to of the feed. You can make this as descriptive as you want… just don’t make it too long. Hint, if you click the override button on the right, it will update only the RSS feed and not the default display.



    +Row Style:  Simply change this to node and update .



    +Then you’ll change the display type in the next screen to anything you want. My preference is “title plus teaser.”



    +Path: You’ll want to be able to find this feed (like if you wanted it to go to Feedburner). I like to use the extension xml so that I don’t accidently confuse it with another path alias.



    +To add a sort and a filter, first click on the defaults view on the left



    +Then you’ll be able to see the + to add those.


    +Sort: You can sort anyway you want, but the most common RSS feed will be a sort with the most recent posts at the top. Select Node: Post date and click “add”.


    +Choose Ascending order and click “update”.



    +Filter: We are going to add a couple of filters. Click the plus next to filters to add a new one.

    +First filter: Node: Post Date



    +You want to make sure that you can post items in the future and make sure that they don’t appear until the publish date. I like to set this filter to 1 minute in the future.



    +Second filter: You want to make sure that if your node is not published, then it doesn’t appear.



    +Then:



    +Third filter:  You will only want certain content types to appear in this RSS feed so you’ll need to create a filter for the Node: Type:



    +Then select one of the node types that you would like to appear:



    +Make sure you click save at the bottom of the page to ensure all your settings are saved.
     
  7. You will likely see an error that indicates this:



    +With the default display selected, you simply need to click on the edit field link here:



    +Then select “node” and update.



    +Then click “update” once more on this screen.


     
  8. Make sure that you hit save on the view once more.
     
  9. Now you can test your feed by going to the path that you set. If you named it as per our tutorial, you’ll go to example.com/blog.xml

Module required for this tutorial:

Views