Actions

Talk

Difference between revisions of "Triggering content plugins in your extension"

From Joomla! Documentation

m
m
Line 9: Line 9:
 
The Example.php in content shows (now wrongly and deprecated in PHP 5.3):
 
The Example.php in content shows (now wrongly and deprecated in PHP 5.3):
  
''function onPrepareContent( &$article, '''&'''$params, $limitstart )''
+
<source lang="php">
 +
        $dispatcher->trigger('onPrepareContent', array (& $item, & $item->params, 0));
 +
        or could be: function onPrepareContent( &$article, '''&'''$params, $limitstart );
 +
</source>
  
but it SHOULD be:
 
  
''function onPrepareContent( &$article, $params, $limitstart )''
+
SHOULD now be:
 +
 
 +
<source lang="php">
 +
        $dispatcher->trigger('onPrepareContent', array (& $item, $item->params, 0));
 +
        or could be: function onPrepareContent( &$article, $params, $limitstart );
 +
</source>
  
  
Line 24: Line 31:
  
 
you may also want to change in file JOOMLA\modules\mod_customcontent\helper.php:
 
you may also want to change in file JOOMLA\modules\mod_customcontent\helper.php:
 +
<source lang="php">
 
  line 36, change the array to: array (& $item, & $params, $limitstart ))
 
  line 36, change the array to: array (& $item, & $params, $limitstart ))
 +
</source>
  
 
Ref: joomlacode.org/gf/project/ianstools/tracker/?action=TrackerItemEdit&tracker_item_id=10578
 
Ref: joomlacode.org/gf/project/ianstools/tracker/?action=TrackerItemEdit&tracker_item_id=10578
  
 
Not sure why this did not make the 1.5.15 ... 1.5.18 releases.
 
Not sure why this did not make the 1.5.15 ... 1.5.18 releases.

Revision as of 12:34, 15 July 2010

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 http://php.net/manual/en/language.references.pass.php


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 ))

Ref: joomlacode.org/gf/project/ianstools/tracker/?action=TrackerItemEdit&tracker_item_id=10578

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