Hi all,

For the moment, I'm quite happy with Drupal 5.1 Aggregator. I've tried other RSS reading modules, but for one reason or the other, they don't seem to reliably do what they're supposed to. So, it's on with the Aggregator module.

I was wondering: how can I style its output? There's an aggregator.css in the /modules/aggregator folder. That's a starting point for the looks, but I would rather also work with a .tpl file, similar to what I'm doing with other content types, to influence the structure of the output. But these other content types are all node-based (node-mycontenttype1.tpl.php, node-mycontenttype2.tpl.php etc.). From what I understand, Aggregator is not node-based. So, how to style the structure there??

Is it possible to have an "aggregator.tpl.php" or something? How should it be called, and where should I put it? Also in the theme folder??

Ludo

Comments

polar-bear’s picture

For customizing styles, I recommend Firebug for Firefox. It is really a amazing software and very useful tool for debugging style. It will save you lots of time trying to figure out which style files to change to achieve the desired look.

There probably will be a number of way to achieve your goal but I did this way.

I have created a block with following PHP code. I got this from someone and modified it. You can do the same.

<?php
// last update 17 Agosto 2006
$categoryid = 2;     // I suggest to assign a category for all feeds. Is easier to manage them later.
                                     // If you don´t want to use it you can remove this line and the one with "where a.cid = $categoryid"
$limit = 3;         // Number of articles I want in my block
$result = db_query("
SELECT ac.title as actitle, af.title as aftitle, ai.title as aititle, ai.link as ailink, ai.timestamp as aitimestamp, af.link as aflink, ai.description as aidescription, ai.fid as aifid, af.url as afurl
FROM sig_p_aggregator_category_item a
INNER JOIN sig_p_aggregator_category ac on a.cid = ac.cid
inner join sig_p_aggregator_item ai on ai.iid = a.iid

inner join sig_p_aggregator_category_feed acf on acf.cid = ac.cid
inner join sig_p_aggregator_feed af on af.fid = acf.fid and
ai.fid = af.fid
where a.cid = $categoryid
order by aitimestamp desc
limit 0,$limit
");

print '<table>';
while( $donor = db_fetch_object($result) ){
  $itemtitle = strip_tags($donor->aititle); // Avoiding images or formats
  $feedtitle = strip_tags($donor->aftitle);

   print '<tr valign=top><td><img src=http://www.kseauk.org/sig-p/img/icon_arrow.gif border=0 vspace=4></td><td><span class="class_for_title_of_article"><A href="' . $donor->ailink . ' "title="'.$itemtitle.'">'.$itemtitle.'</a></span></td></tr>';
}
print '<tr><td></td><td align=right><a href=http://www.kseauk.org/sig-p/aggregator/categories/2>more&raquo</a></td><tr></table>';
?> 
modul’s picture

Thanks, PolarBear, that looks like an interesting approach to my problem. Somehow, I prefer working with .tpl files, to keep things swiftly accessible for editing purposes. Blocks are a bit trickier, I experienced the hard way - i.e. one missing bracket can "block" your entire site. But if you first assign the block to one particular node, it's more secure. So, I'll definitely give your suggestion a try. Thanks again!

And if anyone has any .tpl ideas, they're still Most welcome.

Ludo

vm’s picture

Drupal best practices for using block code : http://drupal.org/node/85694

rather then add it to a block add it to a page or a story, to insure it works before adding it to a block. doing so will throw an error rather then shut the site down : )

polar-bear’s picture

Another advantage of creating a new block instead of modifying .tpl file is that even if you upgrade your theme files (including .tpl files) you don't have to make changes to the new .tpl files if you have it as a block.

Something to think about.

pelicani’s picture

I was looking for this solution as well and came across this post...
http://drupal.org/node/31598

The method I selected was formatting the theme from the template file.
By defining the function phptemplate_aggregator_page_item($item) in my template.php file.
To start, open your aggregator module and copy the existing theme_aggregator_page_item function and paste it in your template file.
Then rename it like above and format as you wish.

peace,
michael

Web Developer : RockRiverStar.com : Philadelphia, PA

Technical Architect : Philadelphia, PA

modul’s picture

Thanks, Pelicani, that was the approach I was actually looking for! I followed your instructions, and it works like a charm. Thanks again!

Ludo