By Joachim Funk on Monday, 03 March 2014
Posted in Technical Issues
Replies 3
Likes 0
Views 609
Votes 0
Hi!

I've a question concerning the module "Most popular post": Is it possible (perhaps with a PHP-funkction) to truncate the description after a last (whole) word and not after x letters in the middle of words? It's not a big problem, but it would look a lot better...

The place to do this is in the helper.php:
$row->summary	= JString::substr( strip_tags( $summary ) , 0 , $params->get( 'textcount' ) ) . '...'; 


Thanks!
Hi Mark,

thanks for your reply. I'm not so good in PHP and solved it in a beginner-style - but it seems to work. Here's the code:


// truncate string
$truncate = JString::substr( strip_tags( $summary ) , 0 , $params->get( 'textcount' ) );
// make sure it ends in a word
$row->summary = substr($truncate, 0, strrpos($truncate, ' ')). ' [...]';


I know, the code is not really clean and there's a better way to do this. So, if this reads a PHP-expert...
·
Monday, 03 March 2014 21:22
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Joachim,

Unfortunately there's no easy work around for this but perhaps you can try something like this,


$row->summary = JString::substr( strip_tags( $summary ) , 0 , JString::strrpos($text,' ') ) . '...';
·
Monday, 03 March 2014 19:28
·
0 Likes
·
0 Votes
·
0 Comments
·
No problem Joachim, as long as it works for you Don't worry, we are all learning! I am still learning too even with over 10 years experience with Joomla
·
Monday, 03 March 2014 21:27
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post