5.6. OPT plugins

Open Power Template supports a plugin system. You may download the plugins from the Internet or just keep your add-ons in separate files and the library automatically loads them during the setup. However, remember that these files have to be included by PHP, which is a bit slower, than storing everything in one, big file (especially if you have many plugins). If your priority is the performance, consider the second solution and linking the new items with registerXXX() methods.

In order to enable plugins, set the plugins configuration directive to the current plugin directory. It must be both readable and writeable for PHP, because OPT needs to save there two files containing information about the directory content, not to scan it every time. Except those two ones, all other files must be named in this way: type.name.php, where "type" is the type of item we want to add. The following types are available:

  1. component - registers a new component class with the specified name. It will be also available under it. Sample: component.sampleComponent.php.
  2. instruction - registers a new OPT instruction processor class with the specified name. Note that the information about registered instructions is read from the class. Sample: instruction.optNewInstruction.php - will register "optNewInstruction" instruction processor.
  3. function - registers a new OPT function with the specified name (it must not contain the "opt" prefix). The function will be available in the templates under the same name. Sample: function.Power.php will register a function "Power", which source code is located in "optPower" PHP function.
  4. prefilter, postfilter, outputfilter - these types represent three content filters available in OPT. They register them under the specified name (without the "optSomefilter" prefix!). Sample: postfilter.Optimize.php will register the "Optimize" postfilter, which code is stored in "optPostfilterOptimize" PHP function.
  5. resource - not tested yet.

Remember that after installing new plugins you have to remove the files plugins.php and compile.php manually from the plugin directory.

By default, the plugins are loaded automatically, when OPT needs them. However, you can call the loadPlugins() manually, which may be especially useful, when working with components on the script-side.