Teaser <50 chars

somes - June 20, 2005 - 11:11

Hi guys any one out there that can give me the easy way of limiting the teaser to 50 characters the defaults in drupal are too large for what i wanna do
theres a function(i think) that you can specify the length of a teaser in the API but i've no idea on how to use it

any thoughts
cheers
M

You could use the excerpt

Development See... - June 20, 2005 - 12:28

You could use the excerpt module which will let you write custom teasers, but won't work if you're trying to limit in a community site. If you want to put it in the module, it is in the node.module and in 4.5 look for node_configure function and then the teaser_length variable, where you should see an array of various lengths that are already in there, so then just add your 50 character teaser.
Ian

Ah thats where you edit it

somes - June 20, 2005 - 22:07

Ah thats where you edit it that works a treat though I was thinking that this is set in the php therefore this limit teasers to one length, is there a call that can be made to the data base where the teaser can be dynamically set

ie for the front page the teaser is 50 characters then on a page listing all the node in a blog the teaser length can be increased to 200 characters.

what functions control where the teaser is set

later
M

function change

somes - June 21, 2005 - 07:21

I've just had a look at the node module and see that it may be possible to change the value using the

function node_teaser($body, $format = NULL)

proposed change
function node_teaser($body, $format = NULL, $size = 50)
function node_teaser($body, $format = NULL, $size = 600)

though I'm not sure where can this be called or inserted in the node output, Is it possible to directly insert the change where i need the smaller teaser though an after thought which might just be easier is to

variable_set('teaser_length', 50);
variable_set('teaser_length', 100);

has any one tried ammeding the variable in drupal
suggestions
later
M

teaser

robwatts - July 4, 2005 - 11:15

I had a similar issue

I edited the line that outputs the form values at /admin/node/configure and changed

Line 160

from

$size = variable_get('teaser_length', 600);

to

$size = variable_get('teaser_length', 100);

and

Line 586

from

$output .= form_select(t('Length of trimmed posts'), 'teaser_length', variable_get('teaser_length', 600), array(0 => t('Unlimited'), 200 => t('200 characters'), .....

to

$output .= form_select(t('Length of trimmed posts'), 'teaser_length', variable_get('teaser_length', 100), array(0 => t('Unlimited'), 100 => t('100 characters'), .....

I haven't figured out how to apply this to existing posts, other than by editing them, which then applies the teaser length.

Seems that when you edit a post the abridged version is put in the db as an actual value, rather than an on the fly string conversion of the full post/story.

the edit doesn't work

radiofranky - November 28, 2005 - 01:03

I tried to edit the lines u mentioned above...
somehow I get T_string error on line 216

I ended up using the excerpt

somes - November 28, 2005 - 08:57

I ended up using the excerpt module instead of messing around with the core... would it work for what you need to do

Superteaser module is

steffen - December 7, 2005 - 22:34

Superteaser module is better, as you don't have to write new text, but you can simply specify a shorter teaser. It will also give you a gentle breakup of the text.

I'm trying to make the

mindprint - April 29, 2006 - 23:56

I'm trying to make the teaser length 0. I don't want to hide the teaser and only have the title link. How do I go about that?

Bump

Zoologico - January 14, 2007 - 15:36

Tracking.

 
 

Drupal is a registered trademark of Dries Buytaert.