Triggering content plugins in your extension

From Joomla! Documentation

Problem with PHP 5.3 when using this example:

PHP Warning:  Parameter 2 to plgContent<MostPlugins>::onPrepareContent() expected to be a reference,
value given in <whichever plugin cause that> on line <xx>

As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a); See

The Example.php in content shows (now wrongly and deprecated in PHP 5.3):

        $dispatcher->trigger('onPrepareContent', array (& $item, & $item->params, 0)); 
        or could be: function onPrepareContent( &$article, '''&'''$params, $limitstart );

SHOULD now be:

        $dispatcher->trigger('onPrepareContent', array (& $item, $item->params, 0)); 
        or could be: function onPrepareContent( &$article, $params, $limitstart );

FIX: -> Going into JOOMLA root and do a global replace through all PHP files will fix this issue.

Furthermore (somewhat related) if you getting the following error:

Warning: Missing argument 3 for plgContent<PluginName>::onPrepareContent() 
in JOOMLA\plugins\content\<PluginName.php> on line xx

you may also want to change in file JOOMLA\modules\mod_customcontent\helper.php:

 line 36, change the array to: array (& $item, & $params, $limitstart ))


Not sure why this did not make the 1.5.15 ... 1.5.18 releases.

Problem with pagebreak plugin:

At least one of the content plugins called 'pagebreak' does fully work in articles, only. In a custom component the '<hr class="system-pagebreak' elements are just removed from the output; this means, any pagebreaks in a custom component's output are ignored.

This happens in pagebreak.php:96:

if ($params->get('intro_only') || $params->get('popup') || $full || $view != 'article')
	$row->text = preg_replace($regex, '', $row->text);

Please be aware of that, using this example!

WORKAROUND: If the view of the custom component is named 'article', the plugin processes the pagebreaks. Still custom components with other views won't be able to use the pagebreaks plugin for their output.

gba 13:01, 18 August 2016 (CDT)