So I am trying to get some customize aggregator content on my site, howver I am having some problems theming the module. The aggregator module has a theme_aggregator_page_item hook, which allows me to create an aggregator_page_item.tpl.php file in my theme folder. I am using PHPTemplate by the way. I activate this theme file by modifying my template.php file. Everything works fine, except for the fact that now each time the theme_aggregator_page_item function is called in the aggregator.module, I get a new date. So my page looks like:
Date1
News Item
Date1
News Item
Date1
News Item
Date2
News Item
Instead of :
Date1
News Item
News Item
News Item
Date 2
News Item
I know why this is hapening. It is because in my aggregator_page_item.tpl.php file there is a bit of code that isn't working. Here is the file:
static $last;
$date = date('Ymd', $item->timestamp);
if ($date != $last) {
$last = $date;
$output .= '<h3>'. date('F j, Y', $item->timestamp) ."</h3>\n";
}
$output .= "<div class=\"news-item\">\n";
$output .= ' <div class="date">'. date('H:i', $item->timestamp) ."</div>\n";
$output .= " <div class=\"body\">\n";
$output .= " <div class=\"title\"><a href=\"$item->link\">$item->title</a></div>\n";
if ($item->description) {
$output .= " <div class=\"description\">$item->description</div>\n";
}
if ($item->ftitle && $item->fid) {
$output .= ' <div class="source">'. t('Source') .': '. l($item->ftitle, "aggregator/sources/$item->fid") ."</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="categories">'. t('Categories') .': '. implode(', ', $categories) ."</div>\n";
}
$output .= " </div>\n";
$output .= "</div>\n";
echo $output;
The problem is that the $last variable doesn't seem to get passed through the themeing functions of the aggregator module. Is there anyway to fix this WITHOUT hacking the aggregator module?
If I must I guess I will make changes in the aggregator module, but I would rather just work in the theme fucntions.
thanks