You are on page 1of 2

FOR NODE TITLE

In node-type.tpl.php replace
<h2 class="title">
<a href="<?php print $node_url; ?>" title="<?php print $title ?>">
<?php print $title; ?>
</a>
</h2>

WITH

<h2 class="title">
<a href="<?php print $node_url; ?>" title="<?php print $title ?>">
<?php
if(($teaser) && ($is_front) ){ //teaser of front page only
$l_title = strlen($title);
$title_len = 12;//change this value to change the lenght of
the node title to display
if($l_title > $title_len){
$title_show = substr($title, 0, $title_len);
$is_space_t = substr($body_show, -1, 1);
if($is_space_t == " "){//if last character is space,
omit it
$title_show = substr($body_show, 0,$title_len-
1);
}
print $title_show;
print "...";
}
else {
print $title;
}
}
else {
print $title;
}

?>
</a>
</h2>
FOR NODE TEASER of custom content type
-This works on Drupal 6 and will work on Drupal 5 as well. (www.geshan.com.np)
In node-type.tpl.php (type is your node type like page or story) replace
<div class="content">
<?php print $content; ?>
</div>

WITH

<div class="content">
<?php if( ($teaser) && ($is_front) ){
preg_match('/(<p>.*<\/p>)/Usi',$content, $matches); //does
the magic as body is always in <p> </p>
$body= $matches[1];
$len_of_body = strlen($body);

$chars_to_show = 66; //change this to change the no of


characters to display
if($len_of_body>$chars_to_show){
$body_show= substr($body, 0, $chars_to_show);

$is_space = substr($body_show, -1, 1);


if($is_space == " "){//if last character is space
omit it
$body_show = substr($body_show,
0,$char_to_show-1);
}
print $body_show;
print "...";
}
else{
print $body;
}
$len_content = strlen($content);
$len_rest = $len_content - $len_of_body;
$content = substr($content, $len_of_body,
$len_rest);//content after the lenght of body

print $content;
}
else {
//for teaser not for front page and full node
print $content;
}
?>
</div>