PHP
Joomla! 6
Joomla! 5
Joomla! 3 (Legacy)
Template Override
Intermediate
Process Content Plugins (content.prepare) on Custom Text
Evaluates shortcodes such as {loadposition}, {loadmodule} and content plugins on arbitrary text from custom components or database queries.
components/com_example/tmpl/item/default.php
<?php
declare(strict_types=1);
use Joomla\CMS\HTML\HTMLHelper;
// Aplica todos os plugins do grupo "content" ao texto informado
$preparedText = HTMLHelper::_('content.prepare', (string) $result->fulltext, '', 'com_example.item');
echo $preparedText;
Uses namespaced HTMLHelper::_('content.prepare') with optional context parameter.
components/com_example/tmpl/item/default.php
<?php
// Aplica os plugins de conteúdo ao texto obtido do banco de dados
$text = JHtml::_('content.prepare', $result->fulltext);
echo $text;
Classic Joomla 3 call using JHtml::_('content.prepare').
Technical explanation and best practices
Whenever a custom component, module or external query needs to evaluate Joomla content plugin shortcodes (such as {loadposition} or {pmsnippet}), run the text through HTMLHelper::_('content.prepare', $text).