I used this recipe to take only the first word of my field and make it into the node's URL (this is a a private website). This works very well. However, I realized that for the title printed on the node page itself, I want the whole field displayed. Is there a way to do that? Here is the PHP I am using:
$limit = 1;
$text = $node->field_name[$node->language][0]['value'];
$text = strip_tags($text);
$words = str_word_count($text, 2);
$pos = array_keys($words);
if (count($words) > $limit) {
$text = substr( $text, 0, $pos[$limit]);
$text = trim( $text );
$text = rtrim( $text, '.' );
}
return $text;
Comments
Comment #0.0
Hanscraft commentedUpdated
Comment #1
gaurav.kapoor commented