Last updated June 18, 2009. Created by tstoeckler on September 27, 2008.
Edited by jhodgdon, heather, XenonofArcticus, Wolfflow. Log in to edit this page.

In this example you will create a Feed display to show nodes by individual users, dynamically selected through the URL. You will become familiar with the Views 2 interface, as well as learn how to use an argument to pull in a user name and use it in a dynamically created path.

A feed is a data format that places your site's content into a file that can be read and displayed by news reader programs. When visiting a site, you may notice a small RSS transmission icon, whereby clicking on it, you can subscribe to the site's most recent content. This makes it easier for your visitors to keep up to date with your website. You can also use this format to aggregate information into other sites. For more information, please watch a video from Common Craft about RSS in plain English.

Note, Drupal automatically creates a feed for your website, but you may want to create feeds with specific information. In this case, a list per user.

  1. Creating a new view
    1. Go to Administer >> Site building >> Views >> Add to add a new view. Give it the name 'user_feed', description 'A feed of user nodes.', tag 'users', type 'Node' and click Next.
  2. About the Interface. You have been brought to the Views User Interface. As you start, you are editing the "Default" options for the view. In the 1st column on the left- you can see the pull-down menu offers 'Feed', for example, to select settings specific only to RSS views. In the remaining columns, you will be able to add or change options by clicking on links or icons. These options appear below this main area. Most likely, you will need to scroll to see the options appear. As you make changes, these options will appear in bold until you save your view.
  3. Change default display
    1. Under Basic Settings in the 2nd column, click Row style: Fields
    2. A menu loads below, Defaults: How should each row in this view be styled, check the Node option, and click Update.
    3. This loads another options menu, Defaults: Row style options click Update.
  4. Create the RSS view
    1. In the 1st column, select 'Feed' in the drop-down menu, and click Add Display.
    2. Under Basic Settings in the 2nd column, click Row style:Missing style plugin
    3. Note, options appear below the Views Interface, you may need to scroll to see Feed: How should each row in this view be styled
      tick Node, then Update
    4. This loads the next options menu- Display type: select "Use default RSS settings", click Update.
  5. Set the path for accessing your feed
    1. In the 2nd column under Feed settings, click Path: None
    2. In options below Feed: The menu path or URL of this view enter in the path with an argument feeds/%/rss.xml
    3. Click Update
  6. Set up your arguments to say which user's nodes to display
    1. To the right of Arguments, click the + sign to add an argument
    2. In the Feed: Add arguments menu that loads below, select User in the pull-down menu
    3. Check the box User: Name, click Add
    4. Scroll down to options to find Case in path: select Lower case
    5. Check the box Transform spaces to dashes in URL
    6. Click Update default display
  7. Sort to show most recent at top of feed
    1. Scroll up to Sort criteria in the right most column and click the + icon.
    2. In the Groups drop-down menu below, select 'Node', then check Node: Post date, and click Add.
    3. Select Descending Sort order. Click Update.
  8. Set filters to hide unpublished entries
    1. Click the + icon next to Filters. In the options below, select Node under Groups drop-down menu, choose the Node: Published filter, and click Add.
    2. Check the box Published. Click Update default display
  9. Test
    1. Click Save
    2. Under Live preview type in the name of a user, in lowercase, replacing spaces with dashes, click Preview.
    3. You should test and find your feeds at URLs like http://example.com/feeds/user-name/rss.xml
    4. You can use this path for aggregating on another site.

Attaching to a page

When you make a 'view' it can have multiple displays. E.g, a Page and an RSS feed are displays of the same view. You can "attach" the feed to another display.

In this example, let's assume the path for the 'Page' view is set to 'test'.

Let's also assume you have an RSS display for the same view.

  1. Edit the Feed settings. In the bottom of the 2nd column, you can see:
    • Feed settings
    • Path: None -> Click 'none'. Edit in text field to change path to test/rss.xml. Click update.
    • Attach to: None -> Click 'none'. Select [x] Page. Click update.
  2. Save changes.
  3. Click View "Page" (top of the Views Editor)
  4. On your page at http://example.com/test you should see the little orange transmission icon, which links to the RSS feed

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

When setting up the feed, under feed settings, you can also attach it to other pages controlled by a view. For example I created a 6 pages (all tabbed) then selectively created RSS feeds for each page.

so that your users don't have the url next to the feedicon.

Hi there,

I've got this working in Drupal 5.x as well, except for this part:

6. Set up your arguments ...
4. Scroll down to options to find Case in path: select Lower case
5. Check the box Transform spaces to dashes in URL

Any suggestions on how I can get that going in 5.x? My argument is username, and some users have caps and spaces, which could mess up the URL's.

Thanks,
Kevin

hi

here is the code for this view:

$view = new view;
$view->name = 'user_feed';
$view->description = 'A feed of user nodes';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('sorts', array(
  'created' => array(
    'order' => 'DESC',
    'granularity' => 'second',
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'name' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'Alle',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'glossary' => 0,
    'limit' => '0',
    'case' => 'none',
    'path_case' => 'lower',
    'transform_dash' => 1,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
      '3' => 0,
      '7' => 0,
      '6' => 0,
    ),
    'me_redirect' => 0,
    'me_validate_user_argument_type' => 'uid',
    'me_validate_user_roles' => array(
      '2' => 0,
      '3' => 0,
      '7' => 0,
      '6' => 0,
    ),
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'blog' => 0,
      'faq' => 0,
      'forum' => 0,
      'panel' => 0,
      'bio' => 0,
      'group' => 0,
      'page' => 0,
      'profile' => 0,
      'simplenews' => 0,
      'story' => 0,
      'uprofile' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '3' => 0,
      '200001' => 0,
      '200002' => 0,
      '4' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_node_flag_name' => '*relationship*',
    'validate_argument_node_flag_test' => 'flaggable',
    'validate_argument_node_flag_id_type' => 'id',
    'validate_argument_user_flag_name' => '*relationship*',
    'validate_argument_user_flag_test' => 'flaggable',
    'validate_argument_user_flag_id_type' => 'id',
    'validate_argument_php' => '',
    'me_validate_user_restrict_roles' => 0,
  ),
));
$handler->override_option('filters', array(
  'status_extra' => array(
    'operator' => '=',
    'value' => '',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'status_extra',
    'table' => 'node',
    'field' => 'status_extra',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
  'relationship' => 'none',
  'build_mode' => 'teaser',
  'links' => 1,
  'comments' => 0,
));
$handler = $view->new_display('feed', 'Newsfeed', 'feed_1');
$handler->override_option('style_plugin', 'rss');
$handler->override_option('style_options', array(
  'mission_description' => FALSE,
  'description' => '',
));
$handler->override_option('row_plugin', 'node_rss');
$handler->override_option('row_options', array(
  'relationship' => 'none',
  'item_length' => 'default',
));
$handler->override_option('path', 'feeds/%/rss.xml');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
$handler->override_option('displays', array());
$handler->override_option('sitename_title', FALSE);

Thanks a lot for this tutorial in 6.x

I used this view page to replace the standard profile page (with panels module). So I'm trying to display the RSS icon above this view, but I can't.

In 5.x it was pretty simple to display the RSS icon above the view.

Could you please tell us how to display the RSS icon above this view?

Hi All.

First off thanks for the great tutorial! It worked great for awhile however something has broken my user_feed and it is actually been redirected to a one individual user profile. When I click my RSS link to all the posts on my site the proper URL path shows in the address bar for a moment then it changes to (or is redirected to) a new URL path directing it to one of my user's profiles in my site. I don't know why this has happened, I have installed some new modules recently however I can't place specifically which one may have caused the redirect.

Any ideas anyone?

Thanks

why is this archived?

Frontend developer at Torchbox

From the Revisions to this page: "This is a duplicate of the help/views/example-user-feed section of Views Advanced Help, so I am archiving the page."

Perhaps there should be a sign at the top of drupal.org that says "We assume you've read all the Advanced Help documentation."

Was only asking and since then figured it out myself. Funnily enough by re-reading the advanced help.

If its a stupid question you dont have to answer!

Frontend developer at Torchbox

I could not figure out how to make an RSS for my custom view page until I read this article. "Attaching to a page" was a lifesaver.

Cheers!

venusrising

THANK YOU ! for posting this how-to !!! Users like you make working with Drupal bearable.
Has anyone figured out how to move the RSS icon to the top of the views page ?

Motorcycle How-To goes Open Source
http://www.motohowto.com/

Any idea how I can remove the <!—break—> from the RSS feed?

"Any idea how I can remove the from the RSS feed?"

searching for the same !

not sure why this page is archived, but it did the trick for me. thank you!!

I agree, I found this to be extremely helpful. Thank you!