J3.x

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

From Joomla! Documentation

(Marked this version for translation)
m (Add language tag on links)
Line 2: Line 2:
 
<noinclude>{{Joomla version|version=3.x}}{{Joomla version|version=2.5|status=eos}}</noinclude>
 
<noinclude>{{Joomla version|version=3.x}}{{Joomla version|version=2.5|status=eos}}</noinclude>
 
<translate><!--T:1-->
 
<translate><!--T:1-->
A common example of [[Supporting plugins in your component|using plugins]] is to run the '''content plugins''' on some text. This is useful if you want to support plugins that usually work on Content from a custom extension. For the content prepare trigger you can simply call:</translate>
+
A common example of [[S:MyLanguage/Supporting_plugins_in_your_component|using plugins]] is to run the '''content plugins''' on some text. This is useful if you want to support plugins that usually work on Content from a custom extension. For the content prepare trigger you can simply call:</translate>
  
 
<source lang="php">
 
<source lang="php">
Line 25: Line 25:
  
 
<translate><!--T:3-->
 
<translate><!--T:3-->
You might want to look at core components (for example com_content) for an example. See the [[Plugin/Events|triggers page]] for the possible content plugin triggers.</translate>
+
You might want to look at core components (for example com_content) for an example. See the [[S:MyLanguage/Plugin/Events|triggers page]] for the possible content plugin triggers.</translate>
  
 
<translate><!--T:4-->
 
<translate><!--T:4-->

Revision as of 06:52, 26 July 2019

Other languages:
Deutsch • ‎English • ‎Nederlands • ‎español • ‎français • ‎中文(台灣)‎
Joomla! 
3.x
Joomla! 
2.5

A common example of using plugins is to run the content plugins on some text. This is useful if you want to support plugins that usually work on Content from a custom extension. For the content prepare trigger you can simply call:

$text = JHtml::_('content.prepare', $text);

For any other content triggers you must call:

$article = new stdClass;
$article->text = $text;

// add more to parameters if needed
$params = new JObject;

// Note JDispatcher is deprecated in favour of JEventDispatcher in Joomla 3.x however still works.
JPluginHelper::importPlugin('content');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onContentPrepare', array('some.context', &$article, &$params, 0));

You might want to look at core components (for example com_content) for an example. See the triggers page for the possible content plugin triggers.

Also for PHP5.3 compliance please look at the discussion page.

Please look at the discussion page concerning Joomla! pagebreak plugin. gba 05:02, 18 August 2016 (CDT)