How to write Plugins for ARC2

semsol edited this page Mar 14, 2011 · 1 revision

ARC can be extended with third party plugins if those files follow certain conventions, as described on this page:

Name your extension MyPrefix_MyExtensionPlugin, save it as MyPrefix_MyExtensionPlugin.php, and place the file in the plugins directory. The prefix and the extension name must not contain underscores.

If you are using a prefix that differs from "ARC2" (e.g. "MyApp"), you can alternatively place the plugin in a sub-directory of plugins (e.g. plugins/myapp/MyApp_MyExtensionPlugin.php), for example as a bundle including additional files. The directory must have a lowercase name.

If you follow these conventions, ARC will be able to find and include your plugin:

$my_ext = ARC2::getComponent('MyPrefix_MyExtensionPlugin', $config);

In the class file itself, you should add your name, a basic description, and possibly a link to the ARC and/or Plugin website. You also have to define a parent Class (use Class if you don't extend a particular component).

Below, you can see a basic template for an ARC Plugin.

homepage: ARC or plugin homepage

class:    ARC2 My Extension Plugin
version:  yyyy-mm-dd


class ARC2_MyExtensionPlugin extends ARC2_Class {

  function __construct($a = '', &$caller) {
    parent::__construct($a, $caller);

  function __init() {

  /* plugin code */