GiriGiriPHP
home | about | download | how to


Flattr this
How to add a module
modules/ folder
You will find a module folder named 'example' in modules/ folder. Copy this folder, to a new folder with the name of your module. Say, newmodule.

Afterwards, open info.php in the new folder which you just named 'example'. You will find an array containing info about the module, and an array containing actions of the module.

$gb->modules['example']['actions'] = array(
'admin_index'
);

$gb->modules['example']=array('key'=>'example','dir'=>'example','dependency_list'=>array());

Change the references to 'example' to the name of your module. In this case, 'newmodule'.

Then, open up the file class.php in this folder. Change any references to 'example' to the name of your module, 'newmodule'. This includes the class name at the top :

if(!class_exists('example'))
{
   class example
   {


    ...........

And, the initializer of the class , at the bottom :

$example = example::initialize();

Then, go into languages folder - now, there is only a directory named english. Go into it, and open up the general.php file. That is the general include of the language entries for that module. You will find only one entry :

$gb->lang['example']['ANEXAMPLELANGUAGEKEY']='Example language value';

That is just an example. Change the reference 'example' to 'newmodule', and that will be a valid language entry for your new module.

ANEXAMPLELANGUAGEKEY is the key carrying the value on the right.

Duplicate that line, and add as many language keys and value pairs by changing the key as needed.

Your new module is ready. Apart from any database tables your modules may use (depending on what you will be doing), everything is now ready. All you need is to add your actions, and then assign permissions to use it. You can refer to the Adding an action section of the how tos. For assigning your new module to pages so that that action of your module loads by default when that page is requested (as opposed to being requested by a GET or POST string), see Adding a page how to.