Styling and Theming Aggregated Feeds

Events happening in the community are now at Drupal community events on www.drupal.org.
tfo's picture

I'm working on a project that involves refactoring a content site while upgrading from Drupal 4.x to 5.x. One of the pieces I thought would be somewhat easy—displaying recent posts from blog feeds—has turned into a roadblock.

The desired outcome is to have the latest post from each of several external (i.e., non-Drupal) blogs show up such that the title of the blog links to the blog and the title of the post links to the post.

Let me describe where we started, what we tried, and where we wound up.

At first, we thought it would be easy just to use the Aggregator module in core. We set up a block for each blog we wanted to aggregate and compiled them into a mini panel. So far so good.

But then we noticed that for each blog, a "more..." link was showing up. This turned out not to be themable because the "read more" functionality is hard-coded into Aggregator's hook_block override. As far as my Drupal knowledge is concerned, there is no way to override module functions or to leverage hooks without writing a module.

So then we made an attempt using Feed API. We got fairly close to where we wanted to be using Feed API, Feed API Node, Feed API Node Views, Feed API Inherit, and a custom CCK content type for feed items. Unfortunately, the refresh function in Feed API never worked reliably, and we had issues with it seeming to remember feed items that had been deleted. Testing became difficult.

Basically, all we need is some way to get blog titles, post titles, and the corresponding links and to be able to format them the way we want.

It seems like overkill to write our own module (which would basically be a copy of core with just a few bits removed from aggregator_block). Does anyone have other recommendations?

Comments

What about the FeedAPI 'Lightweight' Aggregator?

TKS's picture

Did you try the FeedAPI aggregator module? It basically emulates the core aggregator module, but its most of its functions are themeable -- and it seems to be much, much simpler than the FeedAPI Node side of things. Definitely less quirky in terms of updates, deleted items, etc.

For example, I needed to add publication dates to the headlines that appear in the block for each "lightweight" feed. That's handed by the function theme_feedapi_aggregator_block_item, so all I did was copy it over to my theme's template.php, and make the following changes:

// ==================== Override of theme_feedapi_aggregator_block_item ==========
// ==================== To add date to items listed in blocks ====================


/**
* Format an individual feed item for display in the block.
*
* @ingroup themeable
*/
function phptemplate_feedapi_aggregator_block_item($item, $feed = 0) {
  global $user;

  if ($user->uid && module_exists('blog') && user_access('edit own blog')) {
    if ($image = theme('image', 'misc/blog.png', t('blog it'), t('blog it'))) {
      $output .= '<div class="icon">'. l($image, 'node/add/blog', array('title' => t('Comment on this news item in your personal blog.'), 'class' => 'blog-it'), "iid=$item->iid", NULL, FALSE, TRUE) .'</div>';
    }
  }

  // Display the external link to the item.
  $output .= '<a href="'. check_url($item->link) .'">'. check_plain($item->title) ."</a><br />\n". format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i'));

  return $output;
}

The function that includes the "more" link (feedapi_aggregator_block) is not themable, it looks like, but I suppose there are worse sins that hacking that label directly in the module.

Or you could use some of the translation tools to change that label and others the correct Drupal way -- see http://www.developmentseed.org/blog/2007/oct/05/translating-strings-drup... and http://drupal.org/project/l10n_client.

Good luck...

Aggregation

tfo's picture

We're currently in development with a solution with the Aggregation module. I'll report back with results when I've got 'em...

RSS & Aggregation

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: