Module structure

Modules in DIAFAN.CMS based on MVC pattern. This means that one part of the module data is prepared and processed, the other parts are made and these data are displayed on the website. It managed all this controller. This was done in order to be able to arbitrarily edit module design without worrying about data processing algorithm, and vice versa. That is, every developer can renew the appearance of the news module without affecting the algorithm. The module must be sure to have 3 parts:

  • controller – file modules/module_name/module_name.php class Module name;
  • model – file modules/module_name/module_name.model.php class Module_name_model;
  • template – files in the folder modules/module_name/views, file format modules/module_name/views/module_name.view.template_name.php.


The module "news" consists of files:

  • modules/news/news.php – this module controller. It defines what functions in the model to connect what template tags are used in the module.
  • modules/news/news.model.php – module model, which describes the functions of the module. In the model, the data is requested from the database is processing and preparing an array variable $ result for the transmission of information in the module template.
  • files in the folder modules/news/views/... – module templates. The template takes the variable $result from the model and all the data from it are made and displayed on the site.
If you want to make changes to the algorithm of each module, you need to edit the file modules/module_name/module_name.model.php. And if you want to correct the display elements of the module on the site, you need to edit the file modules/module_name/views/module_name.view.template_name.php.

If the module processes the data from the form, then the file will be added:

  • processing – file modules/module_name/module_name.action.php class Module_name_action.

If the module is part of the "Connection", that is used in other modules, it adds one more file:

  • connection – file modules/module_name/ class Module_name_inc.

If the module is installed option, there must be the installation file:

  • installation – file modules/module_name/module_name.install.php.

If the page module should exist regardless of the structure of the site, you can refer to the module file directly. To do this, the file must have the name of modules/module_name/module_name.function.php. Refer to it as you can:

  • direct appeal – file modules/module_name/module_name.function.php.

The module can communicate with other modules . To do this, you need to prepare files in the format provided by third-party modules.

Of special note is the module JS-scripts. They also involve some peculiarities.