Read more link for truncated descriptions only

Permalink
I'm aware that the page list block offers truncated descriptions after a predefined number of characters by using
if(!$controller->truncateSummaries){
echo $cobj->getCollectionDescription();
}else{
echo $textHelper->shorten($cobj->getCollectionDescription(),$controller->truncateChars);
}

in your view.php. Rather than just hardcoding a "read more" link after every description, is there a way to show it ONLY if it has been truncated?

In other words, if the entire description is showing on the page list, there is no need for the read more link, however if there is more to read, show the link. Any ideas?

hursey013
 
mose replied on at Permalink Reply
mose
One thought that comes to mind is to first save $cobj->getCollectionDescription() in a variable. Then, echo the shortened version of that variable. Finally, compare the length of that variable to $controller->truncateChars, and if the length of the variable is longer, add the more link.