Drupal Mystery #1: Teasers

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.)

Fellow Drupalites! What are your Drupal Mysteries?

Average: 4.2 (15 votes)

Trackback URL for this post:

http://www.drupalace.com/trackback/8

Re: Drupal Mystery #1: Teasers

Well I tamed the teaser like this here.

Re: Drupal Mystery #1: Teasers

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.

Re: Drupal Mystery #1: Teasers

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.

Teaser module

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.

Re: Drupal Mystery #1: Teasers

>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

Re: Drupal Mystery #1: Teasers

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.

Re: Drupal Mystery #1: Teasers

Dude,
Amen

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.

Re: Drupal Mystery #1: Teasers

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.

Re: Drupal Mystery #1: Teasers

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.

Re: Drupal Mystery #1: Teasers

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!

Re: Drupal Mystery #1: Teasers

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

Re: Drupal Mystery #1: Teasers

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

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><br><p>
  • You may quote other posts using [quote] tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
Sorry for the "captcha" spam-detector challenge; the spammers have been out in force. : (
sho_lifting: