Theming two Drupal aggregator blocks separately

1.3k views Asked by At

I'm fairly new to Drupal but have played with it for a while now - but this one's stumping me:

I've got two aggregator blocks on a site that I'm currently building. Is there a way of theming the whole block? Secondly, is there a way of theming the whole block depending on which aggregator it is?

I can theme individual items through theme_aggregator_block_item. However, this themes items within both of my aggregator blocks. I'd like a different output for the items depending on which aggregator it is.

I've tried the block-aggregator.tpl.php approach but any changes I make within that file do not get reflected (even after clearing cache). I'm putting this file in my theme directory and my theme directory/templates (just to make sure) and still getting nowhere. Other things are being overridden when I place them in this folder. Also, I can't see how this would enable me to theme one or the other.

I'm imagining that it's possible with a if($block_name_var == 'aggregator 1') { // do this } type approach but I cannot seem to get the block template to theme it in the first place.

Any thoughts or ideas would be appreciated.

1

There are 1 answers

1
Matt V. On BEST ANSWER

The Theme developer module is useful for determining how to override a particular part of a site. It will tell you what theme functions or template files are currently being used and what your options are for overriding them.

In this case, you can theme the whole block by overriding block.tpl.php. To theme the different aggregator blocks separately, the block.tpl.php function can be overridden separately by using block-aggregator-feed-1.tpl.php and block-aggregator-feed-2.tpl.php.

As for why your current block-aggregator.tpl.php isn't being picked up, my first guess would be that your theme doesn't already contain a block.tpl.php. When creating new template files, make sure your theme already contains the base template file. See the Core templates and suggestions page, for more detail. Look for the section that starts with "Note: There is a bug which prevents..."