For people who have a base knowledge of the PHP language it is very simple to construct a module. Generally to create a PHP-Nuke module means:
To create PHP files for the users, ie the public part of the site
To create an administrator interface
To verify that everything we have created is in keeping with the PHP-Nuke development rules.
But what about the development rules?
It is a good idea to stop on this point before continuing on to the programming part.
Rule: the modules must be included in the folder modules/namemodule in the public part and the folder admin/modules in the administration part
Rule: the main file of the module included in modules/nameofmodule must be called index.php
Rule: the tables in the php syntax are indicated by prefix. For example Nuke pages will be indicated with "$prefix."_pages, where $prefix takes the value from the config.php file which is nuke by default.
Rule: the location of the images or links must start from the root of your html directory and not from the folder modules/nameofmodule because the files contained in it are included in a file placed in html's root directory that's called modules.php
Rule: to manage the multilanguage function in an optimal way we have to create some text abstractions that we will insert in the files by making a folder called “language” inside the folder of the module. Everything will then be automatically recalled. For example, if we need to create a module that we call Topolino (the Italian name of Mickey Mouse) we must give the possibility to those who use the Italian interface to read "Topolino" and to those who use the English one to read "Mickey Mouse" ; -).
How do we do it?
First of all we create the folder “language” inside the folder modules/topolino We insert in this folder two php files that we will call lang-italian.php and lang-english.php We create an abstraction for topolino, in the lang-italian.php it will be:
define("_TOPO", "Topolino"); |
And in English it will be:
define("_TOPO", "Mickey Mouse"); |
In this way inserting in the module the abstraction "_TOPO" this will be automatically replaced by Topolino in the Italian interface and by Mickey Mouse in the English interface.