Home

Re-theming the aggregator block

tags:

A nice person who shares the same name as a famous hair dude contacted me asking how to the drupal news aggregator block show teasers rather than simple titles. This is for the non-profit "The Epilepsy Support Centre". He pointed to this post where I reference themable function overrides in template.php. Go figure - this site must be googleable.

Theme overrides are really very simple for those brave enough to grep through the module code and do some experimenting. note: this is for drupal v 5.x but the process is the same for any version using a phptemplate based theme.

In this case a simple 'find all' search in aggregator.module for the term 'theme' returns a pretty short list of items, you will notice toward the bottom a few references to "@ingroup themeable". This is the good stuff.

The original code from the module begins line 1317

<?php
/**
* Format an individual feed item for display in the block.
*
* @ingroup themeable
*/
function theme_aggregator_block_item($item, $feed = 0) {
  global
$user;

  if (
$user->uid && module_exists('blog') && user_access('edit own blog')) {
    if (
$image = theme('image', 'misc/blog.png', t('blog it'), t('blog it'))) {
     
$output .= '<div class="icon">'. l($image, 'node/add/blog', array('title' => t('Comment on this news item in your personal blog.'), 'class' => 'blog-it'), "iid=$item->iid", NULL, FALSE, TRUE) .'</div>';
    }
  }

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

  return
$output;
}
?>

There's lots we can do away with here, like the 'blog it' links and the titles themselves since they are part of an aggregator teaser already. Since we know we want the block to mimic the teaser from the aggregator news page the next step is to find how that is generated. Scroll down to line 1355 and you'll see "Format an individual feed item for display on the aggregator page.", the function is "function theme_aggregator_page_item($item)" The part we want to steal is line 1377:

<?php
 
if ($item->description) {
   
$output .= '<div class="feed-item-body">'. aggregator_filter_xss($item->description) ."</div>\n";
  }
?>

Put this all together in template.php inside your theme directory. Replace the part of the function name that reads theme_ with phptemplate_ and you are all set! Here's the final snippet:

<?php
/**
* Format an individual feed item for display in the block.
*
* @ingroup themeable
*/
function phptemplate_aggregator_block_item($item, $feed = 0) {
 
// Display the feed teaser link to the item.
 
if ($item->description) {
   
$output .= '<div class="feed-item-body">'. aggregator_filter_xss($item->description) ."</div>\n";
  }
  return
$output;
}
?>

The added bonus with this change is the block titles won't get ugly like they usually do with the check_plain() filter turning html into ascii characters. You can see the function for the aggregator_filter_xss() filter at line 1395:

<?php
/**
* Safely render HTML content, as allowed.
*/
function aggregator_filter_xss($value) {
  return
filter_xss($value, preg_split('/\s+|<|>/', variable_get("aggregator_allowed_html_tags", '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'), -1, PREG_SPLIT_NO_EMPTY));
}
?>

Happy drupal theming!

wow gold

AWoW Gold,WoW

Gold,WoW Gold,WoW

Gold,WoW Gold,WoW

Gold,WoW Gold,
WoW Gold,WoW

Gold

One of the most fast wow gold

popular aspects of fast safe wow

gold any MMOG is the trade-skill
safe wow gold system. Almost all

MMOGs havesafe world of warcraft

gold professions and trade skills Buy Wow Gold

that players can skill Cheap WoW Gold up to help
Cheap WoW Gold create a
wow gold for sale robust,

fully independent cheapest wow

gold player-based sell wow

gold economy. This wow gold

sale type of game play adds gold

for wow,gold in wow atmosphere,

immersion buy cheap wow gold

and robustness to wow gold us the

gold wow world that would otherwise

not exist. In World of Warcraft, there are
conan gold,
buy conan gold,
cheap conan gold,
cheapest conan gold numerous

full and secondary professions, all
age of conan gold with their

own unique advantages buy age of

conan gold,cheap age of conan

gold,cheapest age of conan

gold and aoc gold benefits. A

player may only select buy aoc gold,
cheap aoc gold,
cheapest aoc goldfrom two full

professions and any number of secondary world of

warcraft gold professions.

Some profession combinations
buy world of warcraft

gold make sense, as
cheap world of

warcraft gold they compliment each
cheapest world of

warcraft gold other quite nicely: Alchemy
sell world of warcraft

gold and Herbalist,
world of warcraft gold

sale,Mining and Discount WoW

Gold Blacksmith and Skinning and wow power

leveling,wow powerleveling Leatherworking. Others

can power leveling,
powerleveling be combined with

virtually any other and wow

powerleveling still be complimentary, like
wow power leveling Tailoring

and power level Engineering.

With powerlevel so many

different combinations cheap

powerleveling it can be
cheap power leveling

difficult to know wow

powerlevel which is the right ones to
wow power level pick for

your powerleveling 60 70

character. Secondary
powerleveling 1 70,
power leveling 60 70 and
power leveling 1 70

professions are extremely useful as well; cooking allows you to make special foods that

give you temporary rs

powerleveling buffs, first aid is
rs power leveling useful for

post-combat healing and lineage 2 powerleveling in large raids
l2 power leveling and

fishing is an excellent source of ffxi gil

rare ingredients for cheap ffxi gil

special items and potions. All buy cheap ffxi

gil professions take final fantasy 11

gil time to level up as well, requiring
maple story mesos a player to

spendmaple story meso hours

roaming through the maplestory

mesos wilderness collecting ore, herbs or killing foes
maplestory meso for cloth pieces

and rare buy maple story mesos

ingredient drops.

Leveling up your buy maplestory

mesos professions can be cheap

maple story mesos,cheap

maplestory mesos frustrating eve isk

and time consuming, yet buy eve isk,
eve online isk the rewards for reaching

maximum skill in these buy eve isk,
cheap eve isk professions is undeniable.

There is lots of lineage 2 adena

money to be made in the player buy

lineage 2 adena economy if you have
buy lineage2 adena the time to
cheap lineage2 adena maintain your

skills cheap lineage 2 adena and

keep farming cheapest lineage 2

adena for l2 adena materials.

Even lineage2 adena the raw
buy l2 adena components themselves

can sell cheap l2 adena for a lot

on cheapest l2 adena the Auction
eq plat House. This is where we can help

you raise your profession skills. With our eq2

gold help, we can get your eq2 plat

profession skills up to 300 and everquest 2

gold farm materials and components for you to sell or work up your crafting

professions. With our help, your character won't just be
everquest 2 plat a devastating combat

machine, but also a skilled tradesman, creating rare and expensive items to be sold in the

player drive economy.