plg_system_xbtruncstring v1.0.0.0 
23rd June 2019  J3

Joomla JHtml::string.truncate() function has a couple of minor but annoying bugs. See previous article TruncString Bugs and blog post for details. The new System Plugin xbTruncString provides an override for only this function rather than having to override the entire string.php library code (eg by using the mvcoverride plugin) and then maintain it when any part is updated in the core. 

Function declaration:

public static function truncate($text, $length = 0, $noSplit = true, $allowHtml = true)


This will not be available on JED as it represents a fix for bugs that should really be fixed in the core code - and hopefully soon will be if anyone competent to handle the git pull system and the Joomla unit test system wants to pick it up (I am not competent to do either of those things and have no desire to learn - this plugin fixes my problem and that'll do me nicely).

There are some more details in the posts referenced above and on the documentation page. Install the plugin in the usual way and don't forget to enable it. If ever the problems do get fixed in the core code then I'll publish a new version that does nothing and reminds me to uninstall it from those sites where I have used it.


Improvements and bug fixes

  1. The JHtmlString::truncateComplex() function is supposed to correctly handle only counting the displayed characters but it has similar bugs and anyway it doesn't seem to be much used. A better solution would be to improve the truncate function with an additional parameter 'onlycountdisplayedchars' defaulting to false for backward compatibility which would allow the single function to be used.
    JHtmlString::truncate is used about 100 times in Joomla core code, JHtmlString::truncateComplex is used once - when displaying intro text from archived articles.

Possible New features

  1. get the modifications into the core Joomla code



v1.0.0.0 23rd June 2019
First release.