Community & Support

How to style Feed aggregator Block?

When you create aggregate a feed using the core Feed aggregator, it produces a block you can enable. This block is very basic and only shows the Title from a feed in a list.
I know you can style the Feed aggregator node by editing aggregator-item.tpl.php, but how do you style the block?

Comments

Three options

1. Check if the block has a specific class/id and write specific CSS rules.
2. Use Block Theme module to create specific block templates that can be applied afterwards in block settings.
3. Copy your theme's block.tpl.php as block-[module].tpl.php and customize it. In your case it should be block-aggregator.tpl.php

Gabriel Dragomir
Drupal Romania Association
http://drupal.org.ro
http://drupalcamp.ro
http://web.caligraf.ro

I like the idea of a

I like the idea of a template. I've tried using what was found in the aggregator module, but the fields don't render. Any ideas?

<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>

From my trial and error....

I believe that the [somename].tpl.php files that you can copy from the aggregator module folder to your theme's folder are used to style the aggregator PAGE, not blocks. i.e.: http://www.example.com/aggregator/sources/1

I wanted to make three code changes to the rendering of the aggregator blocks. 1) remove the "more" link; 2) remove the "blog this" link; 3) add target="_blank" to each link.

For #1, add this to template.php:
http://drupal.org/node/228051#comment-1673392

For #2 & #3, add this to template.php:

/* modify link items in the aggregator to open in a new window and
suppress the "blog it" icon & links should the module ever be enabled.
(Code removed--not commented out--from this copy of the original function.) */

function phptemplate_aggregator_block_item($item, $feed = 0) {
  global $user;

  $output = '';

  // Display the external link to the item.
  $output .= '<a href="'. check_url($item->link) .'" target="_blank">'. check_plain($item->title) ."</a>\n";

  return $output;
}

Everything else, was cosmetic, so that was handled with CSS.

Any other suggestions?

Any other suggestions?

help

how theming individual item in rss block???

Socionics human network
Vizit.in Hristianstvo social network hristianstvo.org

Hey tytest you can try views

try with views. i did that..

By
Ram

RK

block-aggregator.tpl.php

I found that you need to duplicate the block.tpl.php file and make it block-aggregator.tpl.php - then you can customize within that. There's a tutorial on Lynda.com .

But I can't figure out how to style the list - or add the date to each entry. I don't understand how it's calling the list style - I was expecting to see

    in one of the files - but it's not there.

    Does anyone know how this works?

Oh - this is what is meant

Oh - this is what is meant above - http://drupal.org/project/views it's a module.