Theming the Node Teaser

You can give a teaser its own unique look by using the following condition on any node.tpl.php file:

<?phpif ($teaser) { // node is being displayed as a teaser // Anything here will show up when the teaser of the post is viewed in your taxonomies or front page} else { //all other cases //Anything here will show up when viewing your post at any other time, e.g. previews}?>

Or, if you want to use HTML within the conditions, for example to make two completely different layout within the template:

$teaser vs $page

Note that the $page variable indicates whether a node is standing alone or not, which isn't necessarily the same as whether it's being shown as a teaser. There are legitimate situations where $page == 0 and it's not supposed to be a teaser - for example, when you preview a node. Additionally, $page and $teaser can be set directly by any code that displays nodes via the node_view() function, so it's wise to think about unexpected combinations.

If you wish to provide a third layout for when the node is being displayed as neither a teaser nor a page, try this:

<?phpif ($teaser) { //if node is being displayed as a teaser //Anything here will show up when the teaser of the post is viewed in your taxonomies or front page} elseif ($page) { //if node is being displayed as a full node //Anything here will show up when viewing only your post} else { //all other cases //Anything here will show up when viewing your post at any other time}?>

Additional Flexibility with Negative Logic

There are circumstances where it is necessary to use negative conditional logic (common throughout PHP programming). For example, you could style node layouts to display certain variables when they are 'not teaser' using the following example code:

I would like to show the node teaser in the standalone page, instead of the full node, but not sure how to accomplish it. Additionally, I would like to open the full text in a modal box. I know how to accomplish that for a manually added link, but how to achieve that programmatically for all "Read More links" of a content type?