Create a teaser with Aggregator module?
BryanSD - June 26, 2007 - 00:39
Overall, the aggregator module in the core works fine for me. However, with copyright concerns, I wouldn't mind limiting the feed from various sources to a limited set of lines/characters. In other words, instead of displaying the whole content from a feed, I'd like to create a teaser to the article I'm aggregating.
Does anyone know if this can easily be done with minor modification to the module? If not, which contributed aggregation/news feed module is in favor these days that could do the job?
Thanks, Bryan

Limit Feed Item text
I've been exploring all manner of ways to create teasers with Aggregator feeds and still haven't come up with an implemented solution.
However, my 17 yr-old son created this hack for me, once I identified the relevant function in the module.
Create a copy of your original aggregator.module and then modify the code as shown:
function theme_aggregator_page_item($item) {
$source = '';
if ($item->ftitle && $item->fid) {
$source = l($item->ftitle, "aggregator/sources/$item->fid", array('class' => 'feed-item-source')) . ' -';
}
if (date('Ymd', $item->timestamp) == date('Ymd')) {
$source_date = t('%ago ago', array('%ago' => format_interval(time() - $item->timestamp)));
}
else {
$source_date = format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i'));
}
$output .= "<div class=\"feed-item\">\n";
$output .= '<h3 class="feed-item-title"><a href="'. check_url($item->link) .'">'. check_plain($item->title) ."</a></h3>\n";
$output .= "<div class=\"feed-item-meta\">$source <span class=\"feed-item-date\">$source_date</span></div>\n";
if ($item->description) {
$output .= '<div class="feed-item-body">';
// Hack to limit length of displayed text
if (strlen($item->description) > 300) {
$output .= substr(aggregator_filter_xss($item->description), 0, 300) . '...';
} else {
$output .= aggregator_filter_xss($item->description);
}
$output .= "</div>\n";
}
$result = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = %d ORDER BY c.title', $item->iid);
$categories = array();
while ($category = db_fetch_object($result)) {
$categories[] = l($category->title, 'aggregator/categories/'. $category->cid);
}
if ($categories) {
$output .= '<div class="feed-item-categories">'. t('Categories') .': '. implode(', ', $categories) ."</div>\n";
}
$output .= "</div>\n";
return $output;
}
It's not particularly elegant, but it does limit the display of text from each feed item.
If someone wants to do the
If someone wants to do the same in D6 you can add a theme-preprocess-aggregator-item function to your template with something like:
<?php$teaser = node_teaser($item->description, NULL, NULL);
$variables['content'] = aggregator_filter_xss($teaser);
?>
http://csscreator.com