Develop new module - Part 1 - Module directory structure

From TomatoCMS Documentation

Jump to: navigation, search

TomatoCMS support modular architecture with more than 10 built-in modules. In this series, I will help you how to create new module from scratch.

Structure of module directory

Each module of TomatoCMS is sub-directory of app/modules directory. Looks at this folder, you will see the collection of TomatoCMS built-in modules, there are:

Image:Built-in modules.png


Now, let's explore a module, comment, for example.

Image:comment module directory.png

The comment directory consist of some sub-directories which are:

  • config: This directory consist of module configuration
    • routes: Define all routes that map the URL to module/controller/action following Zend Framework standard
    • about.xml: Module information
    • config.ini: Store module settings in INI format. This file is optional
    • hook.xml: List of all available hook targets of module. This file is optional
    • permissions.xml: Define the privileges which will be called in the back-end
  • controllers: Controller layer. Each file is a controller classes following Zend Framework naming convention
  • languages: Consist of all available languages for module. Each file defines the translation for certain language in INI format.
  • model: Model layer. In most cases, this layer execute database queries
  • views: View layer. This directory consist of helpers and scripts directories defined by Zend Framework workflow.
    • helpers (optional): Contain helper classes which can be called in view scripts
    • scripts: Display what users see in back-end
  • widgets (optional): Contain module widgets. Each sub-directory define a widget

In next guides, I will explain each directory in details.

Personal tools