New module

From Contrexx Wiki (English)

Jump to: navigation, search

Contents

[edit] HowTo programming a new Contrexx CMS module

This tutorial will guide you within six steps to create a new module. Comvation Internet Solutions is willing to pay compensation for your spended time.

[edit] Create module directory

If your module should become a core module: /core_modules/your_own_module

If your module should become a optional module: /modules/your_own_module

[edit] Create module files

Create index.class.php and admin.class.php in the directory you created the step before. You can download this "demo_module.zip" sample where you can find the general buildup and the directory structure.

[edit] Insert modulecode to index.php

Now we have to include the module in /index.php and /admin/index.php:


$modulespath => This is the path to index.class.php or admin.class.php

[edit] Frontend index.php

This is the index.php in your root directory. Edit and insert following code at the switch case section ($section):

[edit] PHP code for core modules


case "your_own_module":
$modulespath = "core_modules/your_own_module/index.class.php";
if (file_exists($modulespath)) require_once($modulespath);
else die ($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
$objYourOwnModule = &new YourOwnModule($page_content);
$objTemplate->setVariable('CONTENT_TEXT', $objYourOwnModule->getContactPage());
break;

[edit] PHP code for optional modules


case "your_own_module":
$modulespath = "modules/your_own_module/index.class.php";
if (file_exists($modulespath)) require_once($modulespath);
else die ($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
$objYourOwnModule = &new YourOwnModule($page_content);
$objTemplate->setVariable('CONTENT_TEXT', $objYourOwnModule->getPage());
break;

[edit] Backend /admin/index.php

Edit and insert following code at the switch case section ($section):

[edit] PHP code for core modules


case "your_own_module":
$modulespath = ASCMS_CORE_MODULE_PATH . "/your_own_module/admin.class.php";
if (file_exists($modulespath)) require_once($modulespath);
else die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
$subMenuTitle = $_CORELANG['TXT_DEMO_MODULE'];
$objYourOwnModule = &new objYourOwnModule();
$objYourOwnModule->getPage();
break;

[edit] PHP code for optional modules


case "your_own_module":
$modulespath = ASCMS_MODULE_PATH . "/your_own_module/admin.class.php";
if (file_exists($modulespath)) require_once($modulespath);
else die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
$subMenuTitle = $_CORELANG['TXT_DEMO_MODULE'];
$objYourOwnModule = &new objYourOwnModule();
$objYourOwnModule->getPage();
break;

[edit] Language variables

[edit] Module

You need to create a directory structure for the language variables

/your_own_module/lang
/en
/de
/and so on.

After that you have to create in every language folder backend.class.php and frontend.class.php. The buildup from backend.php and frontend.php is also available in "demo_module.zip"

[edit] Core System

the core language variables have to be inserted in the according file under

/lang/
($_CORELANG)

Core language variables are global variables which are available not only for a certain module but for the whole Contrexx CMS. In case of adding a new module you have to add a core variable for the backend navigation bar and one containing a description of the module for the module manager.

[edit] Backend templates

Create folder "template" => /your_own_module/template in your module directory. In this directory you have to insert the XHTML templates for the administration interface (Backend)

[edit] Database records

[edit] Module record

Create following record in table contrexx_modules.

   Fields:
       * id -> Module ID
       * name -> Name of module. (Example: shop, gallery, media)
       * description_variable -> Description (core language variable) of module. These is the description displayed in the module manager.
       * status -> 'y' = 'active'; 'n' = inactiv
       * is_required -> If you set this field to the value "1" the module can not be modified in the module manager
       * is_core -> Defines is module core based or optional.

[edit] Modulenavigation record

Create following record in table contrexx_backend_areas for navigation and functions (Have a look at chapter <How to protect functions>).

   Fields:
       * area_id -> Leave blank (autoincrement!)
       * parent_area_id -> 0 if the record should appear as a main-navigation-record, if not insert the area_id from the record above
       * type -> 'group' for main-navigation-record; 'navigation' for navigation-record; 'function' for a function
       * area_name -> Description of the menue/navigation-record. (Have to be a core language variable)
       * is_active -> 1: the record will be displayed; 0: The record will not be displayed
       * uri -> Defines the uri for the record
       * target -> Defines the target of the navigation record (_blank, _self, ...)
       * module_id -> Here you have to insert the module ID of the associated module
       * order_id -> Sortation ID. Will be used for sorting the menue/navigation records.
       * access_id -> This must be a unique, integer number. It mustn't appear second time in table contrexx_backend_areas and in module access tables in the field "access_id".

[edit] Protect module functions (optional)

To protect special functions of a modules and allow to use those functions just to defined usergroups you have to make a record in table contrexx_backend_areas (for general functions) or in table contrexx_module_%MODULNAME%_access (for specific functions).

The accesstable for a new module have following structure:


CREATE TABLE `contrexx_module_%MODULNAME%_access` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(64) NOT NULL default '',
`description` varchar(255) NOT NULL default '',
`access_id` int(11) unsigned NOT NULL default '0',
`type` enum('global','frontend','backend') NOT NULL default 'global',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
   Fields:
       * description -> Description of function. There also a language variable can be used, which will be displayed at the configuration overview of grouprights allowed.
       * access_id -> Defines a unique security id which will be proov the userrights by methode Permission::checkAccess().
       * type -> Defines if function can be used just in frontendarea, backendarea or both.

[edit] Support

For more details look custom essay writing site.

Personal tools
In other languages