Configuration

The first step in the module is defining the configuration data. This includes the module name, version number, author, description. Also, this contains any custom configuration fields. Below is an example of the config function:

Config Function Example
<?php
    function yourmodule_config() {
    	$configarray = array(
        	"name" => "Your Module Name",
        	"description" => "Your Module Description",
        	"version" => "1",//Your Module Version Number
        	"author" => "Author Name",
        	"author_url" => "https://your domain name.com/",
        	"language" => "english",
        	"configs" => array( // Configuration fields 
                    "id" => array ( //Input fields types (password,text,textarea)
                            "Name" => "Field Name", 
                            "Type" =>  "text", 
                            "Size" => "55", 
                            "Description" => "Field Description Here", 
                            "Default" => "Field Default Value Here",
                        ),
                    "isenable" => array ( //checkbox Button
                            "Name" => "Enable mod?", 
                            "Type" =>  "yesno", 
                            "Size" => "55", 
                            "Description" => "A quick way to enable or disable this module on your website ", 
                            "Default" => "", 
                        ),
                    "dropdown" => array ( //Dropdown Select box
                            "Name" => "Select Box", 
                            "Type" =>  "dropdown", 
                            "Options" => "1,2,3,4,5,6,7,8", 
                            "Description" => "Dropdown Description here", 
                            "Default" => "1", 
                        ),
                    "radiobox" => array ( //Dropdown Select box
                            "Name" => "Radio button", 
                            "Type" =>  "radio", 
                            "Options" => "1,2,3,4,5,6,7,8", 
                            "Description" => "Radio buttons Description here", 
                            "Default" => "1", 
                        ),
                    ),
                );
          }


The first 4 fields: name, version, author & description should all be self-explanatory. These contain the display name for the module which will show within the admin area. Also, the version number, name/company of the creator, and a brief description of the addon.

The fields section is where you can define the input you need from end users to be able to make the module work. In this example we are asking for some API related information. Supported field types are “text”, “password”, “yesno” (checkboxes), “textarea”, “dropdown” and “radio”. If using the textarea option, a “Rows” parameter is used to show the height of the box. If using the dropdown type, then you must provide an “Options” parameter with comma separated values.

There is a language variable you can also include if you will be using language files for your module. We’ll look at languages in more detail later on.