Add a custom teaser to nodes

Cuts down body text or any other specified CCK field to a desired length and outputs the result.

Snippet:

<?php
//in template.php:

#custom teaser
function shortenText($text, $length, $node){
   
$text = $text." ";
   
$text = substr($text,0,$length);
   
$text = substr($text,0,strrpos($text,' ')).'...';
   
#$text .= " ".l("...more", "node/".$node->nid);
   
return $text;
}
//function arguments:
//$text - the field to shorten body field is: $node->content['body']['#value'], or CCK field: $field_fieldname[0]['value']
//$length - the length in time you wish to travel.. no wait thats my time machine.. its the length you want the teaser :]
//$node - passes the $node variables to the function to be used cleverly. just write $node

//in node.tpl:
print shortenText($node->content['body']['#value'], 300, $node);
?>