Making the 'Feed' page display items loaded on the feed

It's useful to view the items loaded just by the specific feed. For example it's common in blog or podcast directories to list teasers for items on the "Source" page. The 'Feed' content type that comes with FeedAPI doesn't support listing the items on the same page, however. There is a link, in the links for the Feed content type, to "feed-item/#" that is intended to link to the items loaded by the feed, but this seems to give an error page.

Create a view to list the items

First thing to do is to create a view that will handle the feed-item URL. Create a new view, type is Node, name it 'feed_items'.

Views section Configuration
Filters Node type: Feed Item, Published: yes
Sort Criteria Node post date: descending
Arguments FeedAPI Item: Parent feed
Basic Settings Row style: Node

Now add a Page display. Set its' path to 'feed-item/%'.

Now add a Feed display. Set its' path to 'feed-item/%/rss.xml'. Set style to RSS feed, and row style to Node. Attach the feed to both the Page and Defaults displays.

Once you've done this on a Sources page the 'Feed items' link should now work.

Using a theme template to display the view on the Source page

There are two ways to get the items loaded by a feed onto the Source page. One way is with a theme template for the Feed Item content type and the other way is using Panels. Since Panels is rather complex some people may prefer to use a template. The general idea is to override how Feed nodes are displayed adding an invocation of the above view on the same page.

In your theme directory execute this:-

  1. $ cp node.tpl.php node-feed.tpl.php

Creating a file by that name lets us theme that specific node type differently than the generic node formatting in node.tpl.php. Using node.tpl.php as the starting point is recommended because all we really want to do is append the view at the bottom of the content.

Towards the bottom (before the final </div>) add this following code:-

  1. <?php if (!$teaser) { ?>
  2. <p>Recent posts:</p>
  3. <?php
  4. $view = views_get_view('feed_items');
  5. $view->set_arguments(array($node->nid));
  6. $view->set_use_pager(true);
  7. print $view->render();
  8. ?>
  9. <?php } ?>

Using panels to display the view on the Source page

TBD