When you click a Tag you are directed to Tags results that are rendered by ../components/com_tags/tag/default_items.php. By overriding this file you can have your specific look. A serious issue with the above file is the rendering of the truncated text that has HTML tags and this can result in a breaking layout. For example, if you have an opening Unordered List tag without the closing tag, a usual issue, that breaks the whole layout.

The code (in Joomla 4) that displays the truncated text from the main article text is:

<?php echo HTMLHelper::_('string.truncate', $item->core_body, $this->params->get('tag_list_item_maximum_characters')); ?>

So, the question is: How can we modify the above code to strip HTML tags?

1 Answer 1


I'm not sure if this helps, but there's an option to strip tags. The allowHtml function's parameter set to false will strip tags I guess. I'm sure. https://api.joomla.org/cms-4/classes/Joomla-CMS-HTML-Helpers-StringHelper.html#method_truncate

<?php echo HTMLHelper::_('string.truncate', $item->core_body, $this->params->get('tag_list_item_maximum_characters'),true, false ); ?>

The last argument is for allow or not HTML, in your case set to false will remove all tags.

  • any idea how to implement this on my specific code?
    – geoplous
    Aug 1, 2022 at 14:00
  • The function is: truncate(string text, int length, bool noSplit = true, bool allowHtml = true) : string you can use allowHtml = false
    – Flor
    Sep 5, 2022 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.