/ Published in: HTML
Expand |
Embed | Plain Text
// makeTeaser: makes a teaser for the number of words specified function makeTeaser($text, $numWords) { $words = split(' ', $text); $words = array_chunk($words, $numWords); $output = implode(' ', $words[0]); $output = strip_tags($output) . '...'; return $output; }
Comments
Subscribe to comments
You need to login to post a comment.

How does this correct the HTML? AFAIKS it does a far worse job then core. Core teaser splitter at least tries to take HTML tags into consideration.
You're totally right. I posted this after messing around with a teaser from another CMS.
// makeTeaser: makes a teaser for the number of words specified function makeTeaser($text, $numWords) { $words = split(' ', $text); $words = arraychunk($words, $numWords); $output = implode(' ', $words[0]); $output = striptags($output) . '...';
return $output; }