How to create a Module

Here we go, this is the main developer guide which will help you to use Tendoo as a "Developer Tools" to build powerful web application, by extending his features.

Required files to create a module

Before we start, you should create an empty folder on your computer. This folder will containt module files. Create now a config file, which is a xml document, and name it "config.xml".

Here is an example of this config file.

<?xml version="1.0"?>
<application>
    <details>
        <namespace>helloworld</namespace>
        <version>1.1</version>
        <author>John Doe</author>
        <description>Sample Description</description>
        <main>helloworld.php</main>
        <name>Hello World Plugin</name>
    </details>
</application>

This file has module information such as :

  • Module's "namespace" which is required
  • Module version
  • Module Author
  • Description
  • Main file which is a file located within module directory.
  • Name (for humain)

πŸ“˜

About Version

Version is used to make difference between modules. Tendoo CMS support update during installation, that means a module already installed can only be overwritten by a major release.

You should now create a main file, if you don't do that, Tendoo will assume your Module is a "Library Package", and you won't be able to create UI or interact with Tendoo by anyway.

The main file, as this name suggest is the entry of your module, each time Tendoo is loading, it search for main file first.

For this example, i'm about to create a file named "helloWorld.php" like this.

654

Each module extends default "CI_Model" class, and from this it herits CodeIgniter features and Tendoo CMS features. So create a basic class which extends "Ci_Model" like this :

<?php 
class helloWorldClass extends CI_model
{
    function __construct()
    {
        parent::__construct();
        // Events    
        // load dependency        
        $this->events->add_action( 'after_app_init' , array( $this , 'after_session_starts' ) );        
    }
    function after_session_starts()
    {
        $this->load->model( 'helloWorld_model' );
    }
}
new helloWorldClass;

In the constructor, make sure to construct parent first with "parent::__construct()".

πŸ“˜

Hooks

Tendoo use hooks just like in WordPress. This ensure script loading a the right time, and ensure performance.

Hooks are used to ensure performance. The first hook is " after_page_init". Basically this hook loads scripts after Tendon has successfully loaded. Learn more about hooks.

What about dependency

Tendoo use default CodeIgniter folders to move dependency such as "models", "libraries", "language", "assets"

πŸ“˜

About "Assets"

assets has a special treatment. Their are moved within "public/modules/[module namespace]" folder, with is created if the module has an "assets" folder.

Each of these files will be repacked when removing or extracting the module.