PHP Joomla! 6 Joomla! 5 Joomla! 3 (Legacy) Plugin Intermediate

Trigger onContentPrepare via Helpers\Content::prepare()

Replaces removed Joomla 3 JHtmlContent::prepare() with Joomla\CMS\HTML\Helpers\Content::prepare() in Joomla 5 and 6.

Updated on 24 November 2026 33 copies 139 views
components/com_example/src/View/Item/HtmlView.php
<?php

declare(strict_types=1);

use Joomla\CMS\HTML\Helpers\Content;

echo Content::prepare((string) $text);
Direct modern replacement for removed JHtmlContent::prepare() in Joomla 5 and 6.
components/com_example/src/View/Item/HtmlView.php
<?php
jimport('joomla.html.html.content');
echo JHtmlContent::prepare($text);
Original Joomla 3 syntax using jimport and JHtmlContent::prepare().

Technical explanation and best practices

In Joomla 3, extensions frequently called jimport('joomla.html.html.content') followed by JHtmlContent::prepare($text), which no longer exists in Joomla 5 and 6.

Use Joomla\CMS\HTML\Helpers\Content::prepare($text) directly to dispatch onContentPrepare cleanly without legacy imports.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.