bar top left
bar top right
left curve
right curve

 

In order to create our Hello World module, we will use Build Module, which is the most important submodule of Developer module, since it allows the creation of a base model or skeleton we can use as a start point for our module development. This is a time-saving feature for coding routine processes when we start to develop an Elastix GUI module.

The Elastix version used for this tutorial was 2.2.0.

 

Step 1: Install Developer module

Before we start to develop our first module for Elastix GUI, we must start by installing the Elastix Developer module. We can do this by any of the two methods below:

1. Via Console

By using this command: yum install elastix-developer

2. Through Elastix web interface

Go to the Addons menu, look for Developer module, and click on Install, as seen in the following image:


Step 2: Create the Hello World base module

Once you have the Developer module installed, we can see that we now have the Developer tab on the Elastix menu. We click on it, and it shows its 4 submenus: Build Module, Delete Module, Language Admin y Load Module. We click on Build Module menu, as you can see below:

 

 

The Module Builder is divided in 3 parts: General Information, Location and Module Description. Below is the general view of this module:

 

 

 

 

 

 

 

 

 

 

 

 

 


General Information:

In this section we can define basic module information, like its name, identifier, and the permissions it will have.

In addition, we define basic information of the person who created this module, such as name and email address. These details will be added to the PHP files header generated by the module creation.

 

 

 

 

 

 

Module name: The name of the module, in this case our module will be called Hello World. This will be its menu name.

Module Id: The name of the module folder, which must be unique.

Your Name: Name of the person creating the module.

Your e-mail: Email address of the developer.

Group Permission: Access level of the module.

 

Location:

In this section we choose the location of our new module. Elastix works with 3 menu-levels, but for now we will place our Hello World module as a second-level menu, like you can see in the picture:

 

 

 

 

 

 

 

 

Module Level: Any of the 3 available levels.

Level 1 Parent Exists: Here we define if the parent (or level 1) menu exists. If we pick YES, a drop-down list with all available level 1 menus will be displayed. If we pick NO, like for this example, we will see two text-boxes: Level 1 Parent Name and Level 1 Parent Id, where we can set the new menu name and its identifier.

For this case, we have defined that our Hello World module will be placed as a level 2 module, having Example as level 1 menu.

We recommend you to read the Developer module Manual, since it explains in a more detailed way the location a module may have.

 

Module Description:

In this section we define the module type we will be creating, which can be Form, Grid or Framed.

 

 

Our Hello World module will be Form type, with a text field called Name, as you can see in the image:

 

 

 

 

 

 

 

To add form fields, you have to enter their name in Field Name and choose the type from the Field Type drop-down list :

 

 

Next, click on the button to add it.

If you did this procedure correctly, we will now have a new field called Name in our form, as depicted below.

 

 

 

 

 

 

 

If you wish to delete fields from the form, you only have to select it and click on this button: .

 

Once all the required info for creating the Hello World module is filled, click on the Save button located at the top of the module:

 

 

Then, we will see that our Hello World module now shows up in the Elastix web interface:

 

 

By creating a module through the Build Module page, the following two tasks will be accomplished:

1. Creation of the module menu(s) where the module will be placed into. In our case, the level 1 menu called Example, and the level 2 menu with our module name.

2. Generation of the programming skeleton, located in the modules folder within the Elastix framework. The corresponding module folder will have as name the id given from the Build Module interface, which must not be repeated. The Hello World module folder is called hello_world, because this was the name we chose as identifier.

Step 3: Modify PHP files

Once the base module has been created, we will see the following structure inside the path /var/www/html/modules, where id_module is the module folder name, in this case, hello_world.

 

A module has the same general architecture of the framework, MVC2 model, where:

configs: Contains the configuration file needed for our module. If we use a database, its access settings will have to be definied here.

help: Contains the help file for the module, that is, the user manual documentation for the module, which will be shown when we click on the help button located at the right-top corner of the module.

images: All required image files of our module should be placed here.

index.php: This is the control layer.

lang: Here you can define the multiple language translations of the module.

libs: This is the model layer, where we will place all libraries used by our module.

themes: This is the view layer, i.e. the module layout shall be defined in here.


To continue with our module development, let us modify this file: /var/www/html/modules/hello_world/index.php.

1. Replacing the name of the Save button by Click me.

Look for the function:

function viewFormHelloWorld($smarty,$module_name, $local_templates_dir, &$pDB, $arrConf){ .... }

and replace this line:

$smarty->assign("SAVE", _tr("Save"));

by:

$smarty->assign("SAVE", _tr("Click me"));

 

2. Modifying the saveNewHelloWorld function, so that when the Click me button is pressed, a message saying "Hello World" and the input of the name field is displayed.

Replace the content of the saveNewHelloWorld function by:

function saveNewHelloWorld($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf)
{

$strInformationMsg = "Hello World ". getParameter("name")."!";
$smarty->assign("mb_title", _tr("Information"));
$smarty->assign("mb_message", $strInformationMsg);
$content = viewFormHelloWorld($smarty, $module_name, $local_templates_dir, $pDB, $arrConf);
return $content;

}

 

Below you can see our Hello World module working as expected:

 

 

You can download the Hello World module here.

We recommend reading the Developer module Manual, which contains further detailed information on how to create modules by using the Module Builder.