Plugin Best Practices

Extending BasePlugin

All plugins should extend org.mangoblog.plugins.BasePlugin. This gives your plugin all the required functions and a set of utilities for managing preferences efficiently.

1. Avoid Hardcoded Paths

Plugins should never assume a fixed location. Both plugins and components can be moved outside the webroot; their paths are defined in the configuration file.

2. Don’t Use Tags for Output

  • Tags should only be used for layout.

  • Plugins relying on tags may break if the plugin’s folder structure changes.

3. Minimize Access to Global Scopes

  • Avoid direct use of server, application, request, or session variables.

  • Fetch necessary data from the current event.

  • Store variables within the plugin’s own scope.

  • The application scope is unnecessary because plugins persist for the lifetime of the application.