Wednesday, February 6, 2013

How to truncate title or introtextfield with Joomla!


We can use truncate() method to break the introtextfield or title of module or component view at a word boundary.

Exemple Using JHtml::


// load JHtmlString Class
JLoader::register('JHtmlString', JPATH_LIBRARIES.'/joomla/html/html/string.php');
// truncate()method break the introtextfield at a word boundary
echo JHtmlString::truncate(strip_tags($item- >introtext), 53);


Exemple Using JHtml::_


// no need to load class, you can call method directly by this line
echo JHTML::_('string.truncate', $item- >introtext, $params- >get('introtext_limit'));

Disqus Comments