Blogroll based on aggregator feeds

Last modified: May 7, 2006 - 00:35

This block displays a list of aggregator feeds. This can be considered a type of site-wide blogroll.

<?php
// Last update: May 7 2006
$result = db_query("SELECT a.title, a.url, a.fid, a.link
    FROM {aggregator_feed} a
    ORDER BY a.title"
);
$output = '<ul>';
while (
$feed = db_fetch_object($result)) {
   
$output .= '<li>' . l($feed->title, $feed->link) . '</li>';
}
$output .= '</ul>';
$output .= '<p><a href="/aggregator/sources">more</a></p>';
return
$output;
?>

Other suggestions:

  • Add a LIMIT command
  • Figure out the SQL to limit this to a particular aggregator category
  • Figure out the SQL to find the time of the last added feed item (sort by most recently updated)

Drupal Planet Subscription Block

IbnDrupal - August 27, 2009 - 17:19

If you want to add a subscription block, like the one in drupal planet, do the following:

1. Active the PHP Filter Module
2. Create a new block, give 'subscription' as a title
3. Select the PHP filter
4. Input the following code (which is a slightly modified version of the above)

<?php
// Last update: May 7 2006
$result = db_query("SELECT a.title, a.url, a.fid, a.link
    FROM {aggregator_feed} a
    ORDER BY a.title"
);
$output = '<ul>';
while (
$feed = db_fetch_object($result)) {
   
$output .= '<li>' . l($feed->title, $feed->link) . ' (' . l(t('feed'),$feed->url) . ')' . '</li>';
}
$output .= '</ul>';
$output .= '<p><a href="/aggregator/sources">more</a></p>';
return
$output;
?>

And bob's your uncle.

 
 

Drupal is a registered trademark of Dries Buytaert.