Here is one approach: The
PHx plugin with the use of a custom PHx modifier!
Create a snippet:
phx:character_limit
<?php
$output_truncated = substr($output, 0, $options);
$output_truncated.= "...";
return $output_truncated;
?>
Now use:
[*YOURTVNAME:len:gt=`25`:then=`[*YOURTVNAME:character_limit=`25`*]`:else=`[*YOURTVNAME*]`*]
This will output " ABCABCABCAABCABCABCAFRCFR... " if the TV contains more than 25 characters.
The one above breaks if using SPACES
So use that one for e.g. a URL
-When testing I had the same tv up for a math job that caused the error.
Here is another one:
phx:word_limit
<?php
$retval = $output;
$array = explode(" ", $output);
if (count($array)<=$options)
{
$retval = $output;
}
else
{
array_splice($array,$options);
$retval = implode(" ", $array).'...';
}
return $retval;
?>
[*YOURTVNAME:word_limit=`3`*]