Theming the teaser in full node view

mdupont - February 3, 2009 - 18:12

Hello,

I'm planning a website migration to Drupal and have some nodes where I want to visually differenciate the teaser from the rest of the text, for more clarity.

When editing a node and clicking on the "Split summary at cursor" button, I see a checkbox option with the text "Show summary in full view", so I assume it is possible to display only the teaser or the non-teaser part, even when viewing the node.

Unfortunately I wasn't able to find out how to customize my theme's templates to add something like <div id="node-teaser"></div> around the teaser when in full view. Is it something that can be done? I'd rather edit my templates than relying on a new CCK field - let's keep things as "core" as possible.

Thanks!

You have to create the div

kkobashi - February 4, 2009 - 01:27

The teaser is a separate piece of data stored in the database tables and the node's content is a seperate piece of data stored in the database tables.
The $teaser is a variable made available at the node level. It is a boolean flag that tells you if the node is to be rendered in teaser mode (TRUE) or full mode (FALSE).

The teaser content and teaser mode ($teaser) are not the same thing.

Suppose you have a blog node that you want customized. You would create a node-blog.tpl.php file and put in it the following:

if ($teaser) { // teaser view
  echo "<div class='node-teaser'>";
  echo $content;
  echo "<div>";
} else {  // full view
  echo "<div class='node-content'>";
  echo $content;
  echo "<div>";
}

$content contains either the teaser DATA or the full node DATA.

Kerry Kobashi
http://www.kobashicomputing.com

Is it any way when you view

JohnnyHa - February 4, 2009 - 11:31

Is it any way when you view the full node that you dont get teaser just the content ? Teaser is usually used on your index page and its a bit weird having teaser outputted yet again on another page.

Usually, the teaser is the

MidGe48 - February 4, 2009 - 11:39

Usually, the teaser is the first part of the whole post. But I can see what you mean. That is not a teaser, but a summary or an intoduction

www.ZuNOB.com

Exactly, this is more of a

mdupont - February 4, 2009 - 22:20

Exactly, this is more of a summary, a catchy sentence or two to provide an immediately understandable introduction to the topic of the article. I want it to catch the reader's eye when viewing the full node, as it is the first thing that should be read, and also to mean: "By the way, we have a nice summary here if you don't feel like reading the whole page".

Thank you all for your clarifications, it turns out $teaser is just a flag, I'll then use a CCK-field like CCK Teaser Field.

When I first read your

kkobashi - February 5, 2009 - 04:12

When I first read your question, I interpreted it to mean that you wanted the teaser as part of the full view. That didn't make sense to me because you would be duplicating content not only to the user, but to search engines as well. The point of my answer was to show you that you have full control over rendering of your post.

The best way to solve your problem is to download the CCK module and create a content type. Add a text field called "introduction". I like this idea that you have of the introductory field. I find when I write my articles, the teaser is just too constricting and awkward having to try to write the teaser to blend in with the article. With the introduction, you can write anything.

Kerry Kobashi
http://www.kobashicomputing.com
http://www.kerryonworld.com

 
 

Drupal is a registered trademark of Dries Buytaert.