Drupal Mystery #1: Teasers

25 Jun 2007

Sure, Drupal offers teasers for nodes. In fact, there are three ways that I know of to handle them:

1) Write normally, and let your "Length of trimmed posts:" setting (under Post settings) automatically trim off a teaser at the specified number of characters.

2) Toss a "<!--break-->" tag into your post, at the point where you want to break off the end of the teaser.

3) Use the Node Teaser module to insert a custom teaser field into your nodes.

Yet despite three options, I still wish for proper support for teasers. Here's what mystifies me:

Why is support for custom teasers an afterthought, left to a third-party module (that wasn't even available for Drupal 5 for some time)? Shouldn't custom teasers be at the top of the list of core "of course we've got it!" features for a CMS? Doesn't everyone agree with me on that?

Apparently not! I can hardly imply that the masses are wrong to not demand this feature; I'm only saying the lack of outcry puzzles me.

The first option is unsatisfying for its automated lack of intelligence. A teaser made from the first 200 characters of a post may be fine for some sites, but it seems to me cutting off the teaser at some random mid-sentence spot instead of at a meaningful pause doesn't look too slick. And what if I want 200 characters for some teasers and 600 for others, instead of the same number for all teasers?

The second option would seem to address the above concerns, but maybe not. First, it doesn't even work for me, and I don't know why. (Maybe it won't work if I'm also using Node Teaser?) Depending on the input format I use, the "<!--break-->" tag may remain visible, or be stripped out completely. Yet whether it works or not, polluting the post text with a formatting tag, which may further limit what input formats you can use, seems a bad idea. I want to keep text and formatting separated!

Then there's the big shortcoming of both the above options: by no means do writers necessarily want the lopped-off heads of posts as teasers. In most cases, I want teasers to describe or introduce a post, not read it verbatim. I want custom teasers, dagnabbit!

The third option, Node Teaser, tackles all the above. It's the option I use for teasers, and I strew blossoms at the feet of its developers. I don't know what I'd do without it. My complaint is that its functionality resides in a third-party module, not within the core system. That means tools to support Drupal use aren't likely to assume its presence and work with it.

Case in point: I'm typing this now in a blogging client, ecto. It's great to be able to post willy-nilly to a myriad of blogs from one slick application – except that I lose teaser support. Neither ecto not another client I've tried, MarsEdit, support input into Node Teaser's teaser field. So I'll have to go back and edit the posts via browser anyway. Sigh.

So what's the ideal? A teaser setup for all appropriate nodes, that allows a choice between an automated teaser of custom length (either a globally-set default or a custom value), a teaser set by a "<!--break-->" tag (for those for whom that works), or a custom teaser. All part of core, so support tools like blogging clients will work with the teaser system.

(And yes, I want to evolve to the point where I can contribute to such efforts, not just futilely wring my Doritos-stained hands.)


logoSep 2008: These days, the "<!--break-->" tag isn't giving me problems; that was a temporary issue. So it's back among the available tools for me, though it's still not a method I care for much, as it requires muddying text with inserted formatting commands. 

Fellow Drupalites! What are your Drupal Mysteries?


Unknown Drupaloid's picture


This is something that bothered me ever since i started using drupal. I hated how i would get cut mid sentence and with the added complication of WYSIWYGs a formatting tag is pretty much out of the question. I will however try this Node Teaser module. we need to set up a pettition for this to be in the core in the next update.

drupalace's picture

Glad you agree. I think the following would be great for any node, with three radio button choices that the user must select from:


( ) Set teaser to <input some number> characters. (If left blank, Drupal will use the "Length of trimmed posts:" setting, under Post settings.)

( ) Set teaser to end at "<!--break-->" tag. You must add the tag yourself. <Add warning about what input formats are needed to work well with such tags.>

( ) Input custom teaser. <Follow with input field>


What could be better? : )

Now, do you know anything about the process of actually pushing for some change to be made in core? I would assume there's some formal way of submitting such a request, other than making wishes on a small web site.

dagomar's picture

I couldn't agree more.

I have an even more specific wish; i want to use different body teasers with views! So; i have a block "news" wich should show for example only the title and a 20 word teaser. Then i have a news overview page, which should show title > date > 50 word teaser. My guess is that there is nothing to provide this functionality, except for writing my own custom php snippet for the template.php file.

drupalace's picture

Well, first let's note that Drupal 6 has improved handling of teasers. I've only poked at it a little – I won't have any operational D6 sites until more key modules get updated. But while the new teaser handling doesn't perform every circus trick we might want, it's a nice addition, and I heap great thanks upon the developers.

As for Views: Actually, I think you're hinting at what IS a solution, at least for some setups. To give a node multiple teasers for multiple uses, I'd think you could add fields using CCK – "Teaser 1", "Teaser 2", etc. – and then for each Block or View, just specify which teaser field to use. (Sure, you also have to go and input those multiple unique teasers for each node, but I don't see how any solution could avoid that hassle; after all, those multiple teasers are the goal.)

But I think you're looking for something a little different: automatic teasers (by word-count) for the node, with the ability to set the word count by Block or View. That'd be nice as you could vary teaser length by use, without having to manually input multiple teasers per node. Unfortunately, I don't know how exactly you could do that.

But as long we're on the topic, some other teaser tools:

There's some module that lets you specify teaser length by node type, so you could have Pages use a 100-word teaser, Stories use a 500-word teaser, etc. That's still not what you mention, but for some people it may have interesting uses. Unfortunately, I'm drawing a blank on what module it is – Teaser Management, maybe?

Content templates also let you modify teaser output – though again, I haven't yet properly looked into the function.

Finally, there's CCK Teaser Field, which lets you take any CCK field, and specify that as the default teaser field. (I don't know how that'll clash with the Node Teaser module.) As I've long had odd teaser troubles with this site (and strangely, not with other sites running on the same Drupal installation), I've been eyeing CCK Teaser Field as my possible savior: ditch Node Teaser, create my own new teaser field, and let CCK Teaser Field specify that as the universal teaser field for my posts. I just haven't yet gotten around to trying it out and seeing whether it solves my problems, or even works at all!

So there's no über-tool for doing everything we might want to do with teasers, but there's the next best thing: plenty of smaller tools to mix and match. I need to get on top of these more.

Thanks for the message, dagomar!

Unknown Drupaloid's picture

I know this is a really old post, but thought I'd mention that the break tag shouldn't have spaces in it.

drupalace's picture

Thanks, that's a vital point! Little mistakes with spaces, periods, etc. are the death of code. I fixed the instances in the post.   

gpk's picture

>Shouldn't custom teasers be at the top of the list of core "of course we've got it!" features for a CMS?
For you of course, but someone's got to code it! Maybe the developers have so many things at the top of their "must have" lists ... Correction, the developers have so many things ...

>I want to evolve to the point where I can contribute to such efforts
Therein: the answer. Actually, the answer is in D6. Well, kind of. http://drupal.org/node/193680 : http://drupal.org/node/159981 : http://drupal.org/node/201667

drupalace's picture

I hear you loud and clear re "someone's got to code it". I really didn't want my text to come across as "Why can't those programmers code what I want and not what they want?", and sure hope it doesn't read that way; nuances get lost in writing. For the record, I bow in humbled awe – and thanks! – before the Drupal coders, and only want to express good-natured, friendly, "huh, how about that?" surprise that flexible custom teasers weren't desired by more devs right from the start. If they're satisfied holding off on that feature until 6.x, well, I can be mildly surprised, but I certainly claim no right to complain!

And speaking of 6.x, it looks like the coders are creating a nifty system offering both teasers (automated excerpts of main body text) and – new word here – summaries, the flexible custom teasers I wished for. (Thanks for the links!) Excellent. It's really amazing to watch the progress of the project.

Andrew's picture

Keep in mind, all the functionality you need is in the teasers module. You can almost consider it an advantage that it isn't in core. Core has to be rock stable and you're not going to change it easily. Non-core modules can experiment and grow more easily, changing direction isn't a big group decision, unlike core modules.

Having a minimal core and letting you choose your options gives tons of advantages. The smaller your code base, the faster and more secure a system will be. You can choose between small modules that are cooperative tools, letting the ecosystem grow quickly and in unexpected directions.

Yes, it can be frustrating at the beginning to have to download and install a bunch of modules. Try installing WYSIWYG editors :) Think of all the little modules as contant experiments that help guide the core direction. Once you are used to it, you'll see its a great solution.

drupalace's picture

Oh, I'm completely behind the "little modular add-ons" concept; in any software (or heck, many systems), that's a great thing. I like the Drupal way. I'm only a little surprised that custom teasers separate from body text – which for 5.x, does require a third-party module – wasn't automatically something everyone wanted. No complaints here, just a friendly "huh, that's interesting!".

But a question: Is there a Teasers module? In my 5.x installations, I see nothing with that name in the modules directory... Am I missing something, or is Teasers not the name of the module that handles teasers?

Thanks for the comment! Some very good design background for Drupal newbies who'll read this.

Geshan's picture

Well I tamed the teaser like this here.

drupalace's picture

Thanks, Geshan! For the moment, I'm going to leave my teasers as they are; they seem oddly fragile on this site (not on other sites I work with), and as long as they're more or less behaving, I'm loathe to touch them further. : )

But for some sites, the advanced method you describe could be fantastic. I'm definitely bookmarking this one, and will add a link to my Drupal Resources page.

Unknown Drupaloid's picture

drupal does what you want, druplace, you're just doing it wrong.

drupalace's picture

Er, I don't think things are so simple. What I wish for above is per-node variable-length custom teasers, for 5.x (the target of the article).

The default method of setting site-wide teaser length doesn't allow per-node variation. 

The break tag, which was causing me some trouble at the time, does generally work for me these days. I'll add an update note to the article. But while that takes care of variable length, it still doesn't fulfill the wish for custom teasers (i.e., custom text, not the lopped-off first part of the main body text).

Finally, I don't know whether you count third-party modules as part of Drupal for purposes of your reply, but they do offer some added flexibility. And some problems as well. Also, as mentioned, as non-core add-ons they don't find support among third-party blogging apps, which is too bad.

Now, I know things get much better in Drupal 6! My full wish is as follows:

A teaser setup for all appropriate nodes, that allows a choice between an automated teaser of custom length (either a globally-set default or a custom value), a teaser set by a "<!--break-->" tag (for those for whom that works), or a custom teaser. All part of core, so support tools like blogging clients will work with the teaser system.

Does D6 fully offer that? I don't know yet; will have to explore. But I know it at least comes closer, and that's a great thing!

Thanks for the input!

Unknown Drupaloid's picture

I'm somewhat new to Drupal - bit it seems like there is a lot of this "you're just doing it wrong" attitude out there in the Drupal community.

Not only do you see this attitude in community forums like this one - you can see it in the way that Drupal is designed -- which I think is why a lot of people get turned off of Drupal and they - yes - you saw it coming - head over to Wordpress.org.

There needs to be more empathy for newbies and long time users alike - within the forums and in terms of the design of Drupal - I hold out some hope for Drupal 7 though...

drupalace's picture

Yes, there is a current of "you're doing it wrong" in Drupal forums. Though hearing that, I'm immediately inclined to throw in some qualifiers, like these:

  • Many people who hear "you're doing it wrong" (often me!) actually are doing things wrong. 
  • "You're doing it wrong" isn't necessarily a negative comment; I see it stated often as a neutral fact, followed by helpful advice. 

On top of that, I have to offer sympathy to the real Drupal experts who devote time and energy to the project: They do some great work in aiding newbies, and perhaps could do more, but at the same time they want to actually focus on bettering Drupal and, of course, on making their own stuff with Drupal (that'd be the reason for them to be creating it in the first place!). There's only so much time they can devote to directly helping others.

I'll also note that Drupal does continue to get easier and easier for newbies – D6 more than D5, and D7 (I'm guessing) more than D6. For that, I have to applaud the developers. 

But all that aside, I agree with you: There isn't as much friendly hand-holding for Drupal newbies as some would like. I know it's turned off some people. There's actually a lot of great help on Drupal.org and other sites, but sifting through it to locate the good newbie stuff can be a real pain. Similarly, there are amazingly helpful people on the forums, but there are so many posts that newbie questions often go completely unanswered.

That's where I see a role for beginner-oriented sites, and the recent great crop of books aimed right at beginners. What the busy core Drupal developers don't have time to do, others can step in to do (and they're doing so).

You hit on one key word, though, that everyone maybe can and should have a little more of: Empathy. I hear you on that one!

Kristin's picture

I am so confused about which way to go for customizable teasers in drupal 6. At the moment, we are working on an upgrade, and my drupal 5 site is using the Node Teaser module (http://drupal.org/project/nodeteaser) - not available in drupal 6. For all the reasons that drupalace mentioned, I want a customizable teaser field for drupal 6.

The options seems to be: cck_teaser_field, cck_teaser, or teaser

cck_teaser_field seems to be the only one ready for drupal 6, and I can't find any helpful info on drupal 6 'summaries.'  Where can I go for more information/advice?

Any help much appreciated! Thanks!

- Kristin

drupalace's picture

Looks like cck_teaser_field and cck_teaser are available for Drupal 6, though only as beta or dev versions. No user ratings yet for either on http://drupalmodules.com/ , though.

CCK Teaser Field looks promising. Any plans to give it a test?

Add new comment