1

AS written here Plugin types determine which events a plugin can react to. I am now in the process of enabling 2 tasks. First via installer that does a check before update a download id and second I want to add a javascript snipped to the document head in the backend and frontend of the page for a third party api (authentication key).

The events are: onInstallerBeforePackageDownload and onAfterRender

As I see it currently I have to create 2 plugins for it. Once a plugin of the type "installer" and once of the type "system".

Is that really the case? I would like to offer the user the possibility to manage everything in one plugin. It seems to be a bit "overkill" to have a plugin that checks the DownloadID before an update and to provide a ThirdParty API Key in JS...

2

Joomla's System Plugins are triggered with every page request. Although you can use them for everything, for performance it's better to limit its use.

In some cases you could prefer to use non-system methods in your System Plugin (like what you described).

One of my custom System Plugins does some stuff at the method onAfterRoute(). I also needed to change one Joomla's forms. You can change a JForm via the onContentPrepareForm() method that you see in Content Plugins. However, I wanted to keep all my functionality in one place and didn't want to create a separate Content Plugin. So I used onContentPrepareForm() in my System Plugin.

I have not used the onInstallerBeforePackageDownload event yet. I suppose that you can use that method in your System Plugin as well.

If you use a System Plugin, I would add checks at every function to limit its use. When it's not needed to run the rest of the method, leave as fast as possible. Like if you need to run a method only in the front-end:

// Run this only on the Front-end
if ($this->app->isClient('administrator'))
{
    return;
}
1
  • ah nice yeah i will do it like this because the api key is only needed if a certain module gets loaded and in the module settings.
    – Marco
    Jul 3 at 13:58

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.