Welcome to the Geeks & God Static Archive. Read more »

Theme Drupal Teasers, Full Nodes and Front Pages

User Rating:
4
Average: 4 (12 votes)

Want to theme your node.tpl.php so that your teasers, full nodes, and front page are laid out differently from each other? Here's the magic pieces of code:

The $teaser variable can be used in your node.tpl.php files to check whether it's currently viewing a full page or a preview. So, your node.tpl might look something like this:

<?php if ($teaser) : ?>
Do Teaser Stuff
<?php endif; ?>

<?php if (!$teaser) : ?>
Do Full Node View Stuff
<?php endif; ?>

And, as a bonus tip (today only!) you can also detect the front page teaser views by doing:

<?php if ($teaser && $is_front) : ?>
Do your teaser layout for the front page here
<?php endif; ?>

Enjoy!

teaser?

2

What actually is the teaser in refernce to drupal.

Open Source Enthusiast
http://twitter.com/graphicmist

the simplest way i can sum up

3

the simplest way i can sum up a teaser is as such.

let's say you have a page full of "news" articles.

usually, you wouldnt want to display the WHOLE article, because, depending on the length of the article, users would have to do a lot of scrolling to get to the next.

so a teaser is (often) the title of the article, and maybe the first paragraph with a (read more)-type button. so that if the context of that first article strikes a users' fancy, he/she can delve into that article.