How to Instantly Push Content Using RSS and Feeds Module

Shakib Mostafa // June 2011

Consider this scenario – you have a Drupal multisite and would like a central location to write and publish news.  The news content should be managed in one place yet updated on each of your multisites automatically. The solution is feasible but requires some unique configuration and know how.

Modules involved:

Run down of the modules:

  • CCK - Enables you to create your own fields. This will be used to create a date field for our news item to identify when the news event is happening.
  • Views - Enables you to create a dynamic page to display your content.
  • Views RSS - Enables you to configure yours Views RSS page to display the fields that you pick.
  • Chaos tools - A library suite used by many popular modules like Feeds.
  • Feeds - A module that enables your to pull content from diiferentformat types into Drupal nodes on your site. In this instance the source will be RSS feeds.

On main site:

  1. Install and enable CCK, Views, and Views RSS modules.
  2. Create a content type for News and add a field for it to specify when that event will occur.
  3. Enable the Taxonomy module and create a new taxonomy with the list of all your multisites
  4. Associate the new taxonomy with the News content type
  5. Create a “Feeds” view.
  6. In the Feeds view specify to display published News items in the Filters section
  7. Under the Basic section in views, click Style and select to use RSS Feed - Fields
  8. Add all the fields you will use in your RSS feed: Node: Title, Node: Body, Node: Nid, User: Uid, Taxonomy: Term, Content: Date and Time
  9. In the arguments section, specify to use the Taxonomy: Term as an argument.

 At this point your view should look something like this:

  1. Next, click on the gear icon next to Style. Map your fields to the RSS fields like this:
  1. Make any other desired view settings, save, and review your RSS by going to the URL you specified in the path settings.

On the multisite:

  1. Enable CCK, Feeds, and Chaos tools.
  2. Re-create your News content type with the same fields and the one on the main site.
  3. Create a new content type called Feed with no additional fields
  4. Go to site building, then Feed importers, create a new importer.
  5. Edit the new importer, click on the Basic settings specify Attach to content type: Feed
  6. Fetcher should be set to HTTP Fetcher
  7. Parser should be set to Common syndication parser
  8. Processor should be set to Node processor
  9. Click on settings for the Node processor, select News for content type and Update existing nodes
  10. Click on mapping setting and add the following mappings:
  1. As you see the Author name will be a user ID, assuming you are sharing the same user table. The published date will be the news event date, the item GUID will enable the two items to relate to one another so that they are able to be updated and/or deleted.
  2. Once these settings are complete. Add a new Feed content item by specifying the RSS. Don’t forget to use an argument in the RSS feed to describe which content you want to pull.
  3. Each time cron is ran, the Feeds module will grab the latest updates from the RSS feed and update your items.

On main site:

(This is optional and not recommended for most systems. But if you would like your mulsitites to update each time your save or update a news content type on your main site— do this.)

  1. Create a module on your main site with this code:
function example_nodeapi(&$node, $op) {
  if (($op == 'update' || $op == 'insert') && $node->type == 'news') {
    $core = array('cache', 'cache_block', 'cache_filter', 'cache_page');
    $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
    foreach ($cache_tables as $table) {
      cache_clear_all('*', $table, TRUE);
    exec("wget > /dev/null");
  1. This module will run only if the node operation is either update or insert. And will also only run if the news content type if being affected.
  2. The code clears the cache tables which is required to update the RSS feed.
  3. Then it runs the cron for the Drupal site you want to update
Filed under: