I was wondering if there is a way to display a feed icon in an aggregator block

I know I can do this by hard coding the feed icon into each aggregator block, but I don't want to do this as it would mean making changes to the template each time the feed changes

I've looked through the api and I found the following function: http://api.drupal.org/api/function/aggregator_block/6 which creates the content for the block. Is there any way to override this function?

Comments

dafeder’s picture

Create a block-aggregator.tpl.php file in your theme and load the feed info. Here is mine:

<?php
/**
 * @file block-aggregator.tpl.php
 */

$feed = aggregator_feed_load(substr($block->delta, 5));

?>
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?>"><div class="block-inner">

  <?php if ($block->subject): ?>
    <h2 class="title"><?php print $block->subject; ?></h2>
  <?php endif; ?>

  <div class="content">
    <?php print $block->content; ?>
    <div class="feed-icon"><?php print theme_feed_icon($feed['url'], $feed['title']); ?></div>
  </div>

  <?php print $edit_links; ?>

</div></div> <!-- /block-inner, /block -->
ha5bro’s picture

Having a lot of trouble getting block-aggregator.tpl.php to stick. Is there anything else that needs to be done?

dafeder’s picture

You may need to rebuild your theme registry. See http://drupal.org/node/173880#theme-registry

tran_tien’s picture

I'm sorry but after rebuild theme registry, block-aggregator.tpl.php still not used ?

--- nevermind, it solved now.

rewted’s picture

Any idea how I can make the block look like the aggregator node output?

This is aggregator-item.tpl.php which displays the node.

<div class="feed-item">
  <h3 class="feed-item-title">
    <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
  </h3>

  <div class="feed-item-meta">
  <?php if ($source_url) : ?>
    <a href="<?php print $source_url; ?>" class="feed-item-source"><?php print $source_title; ?></a> -
  <?php endif; ?>
    <span class="feed-item-date"><?php print $source_date; ?></span>
  </div>

<?php if ($content) : ?>
  <div class="feed-item-body">
    <?php print $content; ?>
  </div>
<?php endif; ?>

<?php if ($categories) : ?>
  <div class="feed-item-categories">
    <?php print t('Categories'); ?>: <?php print implode(', ', $categories); ?>
  </div>
<?php endif ;?>

</div>
dafeder’s picture

Sorry, I don't really understand what you're asking. What is it you are unable to do exactly?

rewted’s picture

When you create a new Feed Aggregator entry, both a block and node are created.

The block will display feed content in a list, but only shows titles as a link. It also has a "more" link to the node page.

The node will display all content from the feed (title, link, pubDate, image, etc.). Typically the url to this page is www.yoursite/aggregator/sources/1
Construction of this page is done by the aggregator-item.tpl.php which can be found in the aggregator module dir.

What I'm trying to do is create my own template for the BLOCK, using a format similar to the fields used in the node.

dafeder’s picture

The block template will not give you access to how each aggregator item is displayed. If one template were to do that it would be aggregator-item, but it looks like that's not receiving the information or it would be spitting it out (ie, "if ($content)" seems to return false). If what you want to do is add some content below each title, I think you'll need to use theme_aggregator_block_item().

See: http://api.drupal.org/api/function/theme_aggregator_block_item/6

Try adding $item->description in there under the title.

Hope that helps, I'm not too familiar with this part of drupal myself.

lewie6’s picture

im having exactly the same problem as Tytest

dafeder’s picture

Did you try my suggestion above?

rewted’s picture

Suggestions?