My first plugin

From Aikiframework wiki

Jump to: navigation, search

A plugin file is a file that: - is located in plugin directory (or in a subdirectory) - contains the literal: "* This is a aiki plugin:" - contains a class extends from plugin class (provided by aiki), exactly written as

class MY_PLUGIN_CLASS extends plugin {

- after the mark "This is a iki plugin" there a optional information to describe plugin. This meta information fields are Name,Author,Version,Description (one per line)

 
/*
 * This is a aiki plugin:
 * Name: google analitycs
 * Version: 0.001
 * Description: First plugin for aiki
 * Author: Roger Martin
 */

class ga extends plugin {

    function set_actions(){
        return array ("output_html", "output_body"=>10) ;
    }

    function action( $action, &$text){
        switch ($action){
            case "output_html":
                $text .= $this->"a plugin in action....";
        }
        return true;
    }

}


You don't need create a object (aiki do this work) only a class, where you MUST defined two methods:

  • set_actions() that return a array of action and priorities.
  • action($action,$text) that is called by Aiki core.

Optionaly, you can create this method: - onload, if exists, Aiki call it when plugin is actived.

Personal tools