This leads us to the meat of this article: how to trigger events so implementing plug-ins can act on them. The first thing you need to do is to load your plug-in group. This is done via the following code:
JPluginHelper::importPlugin( 'myplugingroup' );
This will load all enabled plug-ins that have defined themselves as part of your group. The next thing you need to do is get an instance of the JEventDispatcher class:
$dispatcher = JEventDispatcher::getInstance();
Notice two things here. First, we are using the getInstance() method, not new, to create a new instance. That is because we need to get the global singleton instance of the JEventDispatcher object that contains a list of all the plug-ins available.
Next, we need to trigger our custom event:
$results = $dispatcher->trigger( 'onCdAddedToLibrary', array( &$artist, &$title ) );
onCdAddedToLibrary and passed in the artist name and title of the track. Which and how many parameters you pass is up to you. Passing parameters by reference (using an &) allows the plug-ins to change the variables passed in. All plug-ins will receive these parameters, process them and optionally pass back information. The calling code can access the returned values via the array $results (each element corresponds to the result of one plugin). $dispatcher = JDispatcher::getInstance();
--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/groups/opt_out.
seems strange that the docs state to use JEventDispatcher when it causes an error
--