Theming Teaser Views

bobwaycott - May 3, 2007 - 19:47
Project:Content Templates (Contemplate)
Version:5.x-1.1
Component:User interface
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

Is there any way to create two or more teasers and theme separately for different display on different parts of a site?

I have a site that publishes articles. Each article has two imagefields: one large image, one small. On one page is a list of all the articles, but it only shows the large image teaser of each article as a link to the $node->nid. No text shows. I have this enabled via customizing the teaser thru Contemplate and a Views page.

The problem:
Each article has an alternate image that is meant to promote the very latest article on the front page. Again, showing only the small image via a Views block that pulls out the latest alternate image and returns it. It's then added to the front page via Panels. The problem is, I can't theme this smaller image as a teaser thru Contemplate. I can display the image, but I really need a separate teaser for this small image so I can customize it to act as a link to $node->nid for each image it displays.

Again, I have this working with the large image on the articles index page. But so far I can only output the alt imagefield, with no ability to customize the image to work as a link to $node->nid.

The only thing I can think is that I somehow need TWO teasers.

Any assistance on this is appreciated. I've searched all over the site and Google to no avail on this.

#1

jjeff - May 3, 2007 - 21:25

Well you could put a conditional around the different "versions" of the teaser. Perhaps something like this?

<?php
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
 
// put the taxonomy view version of the teaser here
}
else {
 
// put the teaser for all other pages here...
  // probably just something like:
 
print $node->teaser;
}
?>

probably more specific to your need would be something like this:

<div class="article">
<?php if (arg(0) == 'articles') {
 
// We're on a View that lives at /articles
 
print $node->tiny_image[0]['view'];
}
else {
  print
$node->medium_image[0]['view'];
}
print
$node->teaser;
?>

</div>

Disclaimer: above code is off the top of my head and completely untested.

 
 

Drupal is a registered trademark of Dries Buytaert.