3 * template_lite truncate modifier plugin
7 * Purpose: Truncate a string to a certain length if necessary,
8 * optionally splitting in the middle of a word, and
9 * appending the $etc string.
10 * Credit: Taken from the original Smarty
11 * http://smarty.php.net
13 function tpl_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false)
20 if (strlen($string) > $length)
22 $length -= strlen($etc);
25 $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+
1));
27 return substr($string, 0, $length).$etc;