hey guys,

i am searching for a possibility for showing pictures in a block, which is created by the aggregator module with a rss feed. actual pictures are just shown on the seperates side (the side with a list of all items of the rss feed). the block is a list ( < ul >< li >content1< / li >< / ul > ) and there are no pictures shown.

what i want is the following:

1. a list of the last 3 uploaded youtube videos of a special youtube channel in a block. in the block there should be only the thumbnail pictures which should be linked to a seperated side. on this seperated side the details of the clicked video should be shown - including an embedded youtube player with the video.

2. the same should be on a seperated side, but not limited in 3 latest posts.

do you have some tips for me? maybe special examples or a introduction or something like that?

best regards - martin

Comments

Martin P.’s picture

i solved the problem by myself. Fot all the People who are searching for a solution:

A Block which is created with Aggregator Module, has NO TEMPLATE. But u can style the output of every single item in the list bye css and aggregator.module-file modules/aggregator-folder.

In this file there is a function which is named theme_aggregator_block_item - It is in line 717. It should look like this:

function theme_aggregator_block_item($variables) {
  // Display the external link to the item.
  return '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->description) . "</a>\n";
}

I just want the linked picture. You find the image tag in $variables['item']->description; (found out with Devel Tool). But it is between other tags an text in this variable. So i expanded the function. It cuts out the image tag and pastes it between the a tags. You also can add id's and classes for css styling, so that nobody can see, it is a list.

function theme_aggregator_block_item($variables) {
  // Display the external link to the item.
 
$meincontent = $variables['item']->description;

preg_match("#(<img[^>]+?>)#i", $meincontent, $result);
list(, $img_tag) = $result;

  return '<a href="' . check_url($variables['item']->link) . '">' . $img_tag . "</a>\n";
}

Have fun

inversed’s picture

Just wanted to say thanks, this works. And for anyone else trying to do this, instead of editing the module, just copy the function from the aggregator module into your theme's template.php file and rename it to something like this (replace themename with your theme's machine name):

themename_aggregator_block_item()

Beezer75’s picture

just a small modification to include the title and image (add this to your theme's template.php file):

function themename_aggregator_block_item($variables) {
  // Display the external link to the item.

$meincontent = $variables['item']->description;

preg_match("#(<img[^>]+?>)#i", $meincontent, $result);
list(, $img_tag) = $result;

return '<a href="' . check_url($variables['item']->link) . '">' . $img_tag . "</a>\n" . '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->title) . "</a>\n";
 
}
shamseer.ch’s picture

open in aggregator.module from module/aggregator(its core module)

edit the function theme_aggregator_block_item($variables)

comment the line return '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->title) . "</a>\n";

and add 

$meincontent = $variables['item']->description;

preg_match("#(<img[^>]+?>)#i", $meincontent, $result);
list(, $img_tag) = $result;

  return '<a href="' . check_url($variables['item']->link) . '">' . $img_tag . "</a>\n";

save it. then go to template.php of particular theme. that is your default template folder 

add some code 

function themename_aggregator_block_item($variables) {
  // Display the external link to the item.

$meincontent = $variables['item']->description;

preg_match("#(<img[^>]+?>)#i", $meincontent, $result);
list(, $img_tag) = $result;

return '<a href="' . check_url($variables['item']->link) . '">' . $img_tag . "</a>\n" . '<a href="' . check_url($variables['item']->link) . '">' . check_plain($variables['item']->title) . "</a>\n";
 
}

here change your themename with your default themename

then working perfect. i got the result