Skip to content
Kenneth Watson edited this page Apr 24, 2014 · 2 revisions

This page offers a brief explanation on how to develop custom plugin modules for Out Of Eve.

<wiki:toc max_depth="3" />


Plugin structure

All of a plugin's content lives within a single directory, within the plugins directory.

Plugin's extend the Plugin class, and the name of the directory within which your plugin lives should match the name of your plugin class.

For example:

// plugin.php:

<?php
  class myplugin extends Plugin {
    var $name = 'My Plugin';
  }
?>

This plugin would live within the /ooe-path//plugins/myplugin directory. The plugin file is expected to be named plugin.php.

If your plugin will be generating output, templates will be required, and these should be located within the templates directory within your plugin directory. Template files should have the .html file extension.

If your plugin requires a custom style sheet, you may create plugin.css, also within your plugin's directory.

In conclusion, a simple plugin named myplugin with templates and a style sheet would have a directory structure something like this:

  • ooe-path/
    • plugins/
      • myplugin/
        • templates/
          • my_template.html
        • plugin.php
        • plugin.css

The plugin class

Your plugin's primary point of entry will be the plugin.php file containing your plugin class, which extends Plugin.

There are two primary method you need to implement within this class, depending on what your plugin needs to do: getContent() and getContentJson().

getContent() is expected to return the HTML output the plugin generates. This will be fitted into the main content area of the website.

getcontentJson() is expected to return a JSON object/string, suitable for AJAX requests (see the _ajaxtest_ plugin).

Generating output

All output is managed by Smarty templates. These templates are HTML files located within the templates subdirectory within your plugin directory.

Typically your getContent() function will make use of the render() function to generate output.

For example, assuming you have an HTML file named my_template.html in the templates directory, with the following content:

  <span>Your plugin says {$message}</span>

You would call this template as follows, within plugin.php:

  function getContent() {
    $my_message = 'Hello';

    $template_vars = array();
    $template_vars['message'] = $my_message;

    return $this->render('my_template', $template_vars);
  }

This would create a simple page, within the general structure of the website, with the content "Your plugin says Hello".

For more information about Smarty template syntax and usage, please refer to the Smarty documentation.

Enabling plugins

Once your basic plugin structure is in place, you need to enable it.

This can be done by simply adding an entry into the $config['plugins']['enabled'] array in your config.php file.

The ordering of the enabled plugins list determines the order in which plugins are initialised, and if you add your plugin to the menu, the order it appears in the menu.

To disable any plugin, simply remove it from the list of enabled plugins. Removing plugins such as users or mainmenu will break your OOE instance.

Clone this wiki locally