Version 3, last updated by m4rw3r at Jun 08 17:41 2009 UTC

What is a module?

A module is a self contained folder which incorporates a complete (or partially-complete, depending on the module complexity) application folder, a configuration file and occasional admin files.

Example structure in the module folder:

/config.xml
/admin.php 

This "mini-application" structure is then overlayed on the main application directory of Ionize, which means that it is possible to use core CMS files as if they are located in the "mini-application" directory and it is also possible to extend the core CMS files!

Calling a module controller

URI: http://localhost/module_uri_segment/controller/method/

Configuring

To configure the module, you modify the contents of the config.xml file.

Example config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<module>
    <name>Pages</name>
    <description>A page handler</description>
    <uri_segment>page</uri_segment>
    <aliases>
        <alias>
            <segment>comment</segment>
            <controller>comment</controller>
        </alias>
    </aliases>
</module>

The name and description parameters are used for the admin interface, to let the user see what plugins are loaded and their descriptions. The uri_segment is the uri segment which will routes to this module.

Routing directives reside within the aliases tag, they will alias a controller to look like it sits in the application folder, in this case it aliases /page/comment to just /comment. The segment is the segment to match, and the controller is the controller in this module to route to.

The admin section also needs settings in this configuration file, to be discussed when we're implementing the admin interface.

Installing

The module is placed in the modules directory, whose path is adjusted by the configuration setting in application/config/config.php: module_path. In this folder, the modules reside in their own folders, neatly encapsulated.

To install a module, just copy the module folder into the modules directory. Then you have to run the module installer which writes the paths and routes to a cache file: http://localhost/install_modules.php.

(This file needs to be integrated in the admin interface later on).

Libraries which cannot be overridden/extended

The following libraries cannot be extended / overridden in modules as they don't use CI's loader but instead uses the function load_class():

  • Benchmark
  • Config
  • Controller
  • Exceptions
  • Hooks
  • Input
  • Lang
  • Loader
  • Log
  • Output
  • Output
  • Router
  • URI