Organic CMS features a friendly platform for developers to create modules and "widget"-like extensions to the template. Read below to learn how to develop your own module, and to get started right away.

Organic CMS is developed on PHP so basic knowledge of programming logic, and the PHP scripting language is required. Knowledge of OOP (object-oriented programming) is also highly recommended to create modules.

Sample Hello World Module

Filename: helloWorld.css

.bold { font-weight:bold; }
.italic { font-style:italic; }

Filename: helloWorld.php

<?

class helloWorld extends OrganicModules {
    var $module_id;
    var $module_name = "Hello World";
    var $module_author = "emarketed";
    var $module_version = 1;
    var $module_website = "http://www.emarketed.com/";
    var $module_settings = array(
                                'text' => 'Hello World'
                                );

    function __construct() {
    }

    function initialize() {
        $this->load_css('helloWorld.css');
    }

    function admin_output() {
        $html = <<<EOD
            <form method="post" action="modules.php?a=save&amp;id={$this->module_id}">
            <div class="label">Text:</div>
            <div class="field"><input type="text" name="text" value="{$this->text}" /></div>
            <div class="label">&nbsp;</div>
            <div class="field"><input type="submit" name="submit" value="Save Changes" /></div>
            </form>
EOD;
        return $html;
    }
    
    function output() {
        $html = "<div class=\"helloWorld\">{$this->text}</div>\n";
        return $html;
    }

}

?>

Now that you have seen a sample of a module, let's get started on the important aspects of the class structure.

Variables

There are several variables that must be set in each module so it can be seen by Organic CMS. These variables allows you to put any information of your module such as name, author, version, or even your website URL. Below is a list of the variables that you can use.

Functions

There are 2 required functions that every module must have: the output, and the admin output function.

The Output - output()

The output returns the content that is to be shown to the browser.

The Admin Output - admin_output()

This returns the content that is to be shown to the browser when in a module's editor when logged in the admin section.

Optional: The Initialization - initialize()

You can set specific variables or do certain procedures in this function. This function gets called before the output functions.

Optional: Load CSS - load_css()

You can include external css files for your modules for more organization. Just make sure to have all css files located in the same directory as your module's definition file.

Example: $this->load('mystyle.css'); //mystyle.css is located at "templates/sampleTemplate/mystyle.css"