Skip to content
This repository was archived by the owner on Nov 12, 2023. It is now read-only.

PluginsDev

micz edited this page Oct 10, 2015 · 2 revisions

Info on using a plugin here.

Plugins can be a normal plugin or an autoload plugin or both.

Plugin files info

Plugins are stored in ./evn_site/_plugins/, so a plugin named sampleplugin is contained in ./evn_site/_plugins/sampleplugin/.

  • If needed to autoload, a plugin must have an _autoload.php file
  • If needed as a normal plugin, it must have a main.php file
  • [optional] A configuration file named _config.php (more info...)
  • [optional] An util functions file named _util.php (more info...)

Normal Plugins

Normal plugins are activated only when the assigned path is loaded. It's also allowed to call a subpath of the given path.

In the main.php file you must define a class, extending the EvnPlugin abstract class setting the name as your plugin name (all lowercase!).

You must define at least the activate() function that returns the content your plugin want to publish as the content of the given page.

Example from the helloworld plugin.

class helloworld extends EvnPlugin{
  function activate()
  {
    set_template_var('title',' :: This is a Demo Plugin!');
    return '<h2>A Demo Plugin</h2><p>Hello world!!<br/>I\'m a
 <a href="http://code.google.com/p/evinrude/wiki/Plugins">plugin</a>
 activated on the <code>'.$this->incoming_path.'</code> path!!</p>';
  }
}

Autoload Plugins

Autoload plugins are always executed when a page is loaded.

In the _autoload.php file you must define a class, extending the EvnAutoloadPlugin abstract class setting the name as your plugin name (all lowercase!) and adding _auto after it.

You must define at least the execute($args=array()) function that could return the content your plugin want to publish, or an empty string if your plugin acts silently.

Example from the helloworld plugin.

class helloworld_auto extends EvnAutoloadPlugin{
  function execute($args=array())
  {
    return '<div id="autop">Hello world!! I\'m an autoloaded
<a href="http://code.google.com/p/evinrude/wiki/Plugins">plugin</a>!!</div>';
  }
}

Ajax

A plugin can also use ajax calls, defining an ajax function: see the helloworld plugin for an example. More info to come.

Clone this wiki locally