2010-08-26, 17:05:11
sauldraws Wrote:seems solid and simple enough,
I added a truncate/except function - it's rough, but fits my immediate needs, might be helpful for someone else
function the_NM_excerpt() {
global $nm;
echo truncate($nm->the_NM_content(), 125,'...');
}
function truncate ($str, $length=10, $trailing='...')
{
$length-=mb_strlen($trailing);
if (mb_strlen($str)> $length)
{
// string exceeded length, truncate and add trailing dots
return mb_substr($str,0,$length).$trailing;
}
else
{
$res = $str;
}
return $res;
}
I think I would love this, but how do I use it? I tried inserting it into the new manager.php file, but it didn't work when I called the function in a component. I would really love to know how to use this in a component. Thanks