Aggregator headline display with date
This snippet works with the core aggregator module. Place the following code in a block to display a list of all aggregator items. The number of aggregator items that appear is controlled by how long aggregator items are kept (in Drupal, not this snippet) since this snippet is set to display all available items.
This snippet will display all available aggregator item headlines along with their publication date in a single column with the newest items displaying at the top of the list.
This snippet was written to avoid having teasers or body content display because of copyright concerns as well as other reasons. If you don't want teasers to appear publicly anywhere on your site, you can set the user permissions so only the administrator has rights to access aggregator content. Alternatively, (this is a dirty fix), you can delete (at your own risk) the column from your mysql database that holds the teasers in the aggregator_item table. Another way to do this is to use a url redirect to redirect the aggregator pages to the pages you want to be seen.
This snippet is appropriate for use in a block or a page. It was tested with Drupal 5. Your comments are appreciated.
<?php
// Last update: April 23, 2008
$result = db_query("SELECT a.title, a.link, a.timestamp
FROM {aggregator_item} a
ORDER BY a.timestamp DESC");
$output = '<div>';
while ($feed = db_fetch_object($result)) {
$timestamp= $feed->timestamp;
$thedate= date("M. d, Y", $timestamp);
$output .= '<p><big>' . l($feed->title, $feed->link) . '</big><br />'.$thedate .'</p>';
}
$output .= '</div>';
return $output;
?>Here is a version that outputs a link to the source of each item:
<?php
// Last update: April 23, 2008
$result = db_query("SELECT a.title, a.link, a.timestamp, a.fid
FROM {aggregator_item} a
ORDER BY a.timestamp DESC");
while ($feed = db_fetch_object($result)) {
$timestamp= $feed->timestamp;
$thedate= date("M. d, Y", $timestamp);
$value=$feed->fid;
$credit = db_query("SELECT u.fid, u.title, u.link
FROM {aggregator_feed} u
WHERE u.fid=$value");
($credit = db_fetch_object($credit));
$credit_title=$credit->title;
$credit_link=$credit->link;
$output .= '<p><big>' . l($feed->title, $feed->link) . '</big><br /><a href="'.$credit_link.'">'.$credit_title.'</a><br />'.$thedate .'<br /> </p>';
}
return $output;
?>
Aggregrator block with dates
If all you want is to add dates to the aggregrator block, there is a simpler way to do that. (No offense to the author of the code above, he had more problems to solve than just adding dates, and seems to have solved them well.)
Adding dates can be done by overriding the theme_aggregator_block_item function. (If needed, there are even more variables passed to the theme function.) I also added some divs and classes for easier styling. This is the code I use, except for the name of the function, which you should adapt to your own theme name.
<?php
/**
* override theme_aggregator_block_item
*/
function themename_aggregator_block_item($item, $feed = 0) {
global $user;
$output = '';
if ($user->uid && module_exists('blog') && user_access('create blog entries')) {
if ($image = theme('image', 'misc/blog.png', t('blog it'), t('blog it'))) {
$output .= '<div class="icon">'. l($image, 'node/add/blog', array('attributes' => array('title' => t('Comment on this news item in your personal blog.'), 'class' => 'blog-it'), 'query' => "iid=$item->iid", 'html' => TRUE)) .'</div>';
}
}
$output .= '<div class="feed-item">';
$output .= '<div class="feed-field feed-field-date">'.date("d/m/y", $item->timestamp).'</div>';
$output .= '<div class="feed-field feed-field-title"><a href="'. check_url($item->link) .'">'. check_plain($item->title) .'</a></div>';
$output .= '</div>';
return $output;
}
?>