Drupal: Link directly to external URLs for feedapi items

The FeedAPi module is a nice little workhorse module that can create nodes out of item from an RSS or Atom feed.  Couple it with the Views module, you have a very low effort aggregation solution.  But since FeedAPI creates a node for each item, Views will link to the node on your own site when it lists the imported items.  You may actually want to link directly to the original article, in which case you have to do a little more click work.

Some possible  solutions

You could write your own custom_url_rewrite_outbound function, and always replace the drupal path with the external url.  Using this function is called frequently, and it replaces the link everywhere it appears.  You lose some flexibility in that you could never link to the node page for the feedapi item.

You could rewrite the link by theming the output of the View, but this is tedious.  You'd have to redo the work if you switch themes or make it work with a base theme + sub theme setup, if possible.

The Views UI provides a way to rewrite the output of most fields, we can exploit this to link the title to the original URL, with a couple of clicks.  Only losers program nowadays anyway.

Rewriting the title link

This only works if you are using the Fields row style in your view.   I assume you've already created your view, and that it includes the Node: Title field. To rewrite the title link:

  1. Add the orginal url to your view by clicking on the plus button to add a new field and check FeedAPI Item: URL, in the following screen mark the Exclude from Display checkbox and press the update button.
  2. Reorder the fields so that the FeedAPI Item: URL field is above your Node: Title field.  If you don't do this, it won't show up as a replacement term in the next step.
  3. Click on Node: Title to edit it.  Mark the Output this field as a link option and put the FeedAPI Item: URL replacement term in the text input for Link Path.  Uncheck the Link this field to its node option and press the Update button.
  4. Save your changes.

The replacement pattern may vary, but now you should have a view where the title links to the original post.