2

As a component developer I can see how useful is to include events to call plugins so other people can extend you component without hacking your core files.

However I am always concerned about this “callings” to have a negative impact in performance.

If you create a component let ‘call it “com_mycomponent” it is also common to create a folder called “mycomponent” inside the plugins folder, and to make event triggers in strategic points in the component

JPluginHelper::importPlugin(“mycomponent”);

$dispatcher =& JDispatcher::getInstance();

$dispatcher->trigger('OnThisThingToHappen', array() )

What happened if I have several active plugins inside “plugins/mycomponent”? I guess each time you trigger an event all these plugins are going to be loaded and their code interpreted by php to check it the respond to the event? It is not that heavy?

And finally, the question that brought me to write this.

If I have a list view of an Item, can I include an event trigger in the item template? It would run on every item so the loading and parsing of all active plugin in your group would be repeated too.

1

It is not bad by itself.

The problem is what is the additional load that each call is going to generate. For instance, it is straightforward to add a SQL query, then each call executes a query and the view ends executing N queries.

Thus, it is a better option to call a trigger an the start or end of iteration, when the item are ready to be generated.

Finally, JLayouts are an alternative to allow thrid party enhancements, without triggers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.