Search »

Anatomy of a Module

All right! Let's dissect a module. Personally I tend to learn better by viewing an example - so if you're anything like me you might want to take a look at our "Hello World!" example modules as well - that contains three modules you can upload to your Form Tools installation that show off how it works.

All modules are located in the [form tools root]/modules/ folder. Each module has a unique folder name made up of alphanumeric and underscore characters only. For the following page, our module is called "My Module" and its folder is named "my_module". The module name also defines your PHP class namespace, as we shall see.

Required Files & Folders

These files are required for every module. All paths are relative to the module folder, which in our case is found at [form tools root]/modules/my_module/.

More Info This is your main module class, which extends global/code/Module.abstract.class.php and contains the author information, name and description, the module navigation menu, your installation, uninstallation and upgrade code.
More Info This is the first page the administrator will be linked to when clicking on the module on the Modules listing page.
More Info All HTML in Form Tools is rendered via Smarty templates. Other than the required .tpl extension, you can call your template files whatever you want and store whem somewhere in module folder. For consistency with the other modules, we recommend putting it in a templates/ subfolder.
More Info All modules include a library.php file in their root that includes all PHP classes/code.
More Info All modules require a language file in the language of the developer. For US English, this file would be called en_us.php. We use the ISO 639-2 standard for the language file names.


More Info Any Smarty functions and modifiers should be placed in this subfolder. They will be automatically loaded and available within your module pages.

The following pages explain each of these files and folders in more depth.