Module Registration

Each module must be registered in configuration storage (Db table “Configuration”) prior to its usage.

For your reference, Vivvo's default modules are instanced during installation of Vivvo (/installer/index.php. lines 1050-1080).

Registering custom module

You can register module using special register_module() register action handler/method, which is probably the most convenient and fastest method to register new module.

Description

void register_module (string MODULE_NAME, string CLASS_NAME, string PATH_TO_FILE);

Example:

$sm =& new vivvo_lite_site();
$sm->register_module('box_comments', 'box_comments', 'lib/vivvo/box/vivvo_box.php');

Un-Registering custom module

You may un-register the module using unregister_module(); method.

Example:

$sm->unregister_module('box_comments');

Registering module directly in Configuration SQL table

Alternatively, you can register the module directly in “Configuration” database table, without using register_module() method.

$query = "INSERT INTO `".$tbl_prefix."Configuration` 
(`id`, `variable_name`, `variable_property`, `variable_value`, `module`, `domain_id`, `reg_exp`)
	VALUES 
(...)

Module registration elements

Each registered module has two elements/rows in Configuration table - the physical PHP file where the module class is, and the module class itself.

Class name:

Parameter name Value Description
variable_namestring the name for the box that is referenced through <vte:box> i.e. “box_comments”
variable_property'class_name'
'file'
distinguishes what you actually register, class or file; i.e. “class_name”
variable_valuestring value for the class_name param i.e. “box_comments”
module'modules' module type, i.e. “module”
domain_idinteger for future enhancements, not used at this point

File:

Parameter name Value Description
variable_namestring the name for the box that is referenced through <vte:box> i.e. “box_comments”
variable_property'class_name'
'file'
distinguishes what you actually register, class or file; i.e. “file”
variable_valuestring value for the file param, path to PHP module file i.e. “lib/vivvo/box/vivvo_box.php”
module'modules' module type, i.e. “modules”. For more on module types, refer to THIS
domain_idinteger for future enhancements, not used at this point

You do not need this information if you use register_module() method!

Examples

Example #1: Most convinient and fastest way is to register module via $site_manager.

$sm =& new vivvo_lite_site();
$sm->register_module('box_sections', 'box_sections', 'lib/vivvo/box/vivvo_box.php');

Example #2: Another way is to register module via SQL directly, i.e. in default Vivvo installer.

(NULL, 'box_sections', 'class_name', 'box_sections', 'modules', 1, NULL),
(NULL, 'box_sections', 'file', 'lib/vivvo/box/vivvo_box.php', 'modules', 1, NULL),

First SQL insert tells vivvo that module named 'box_sections' uses box_sections class and second that that class is located in vivvo_box.php (path relative to vivvo root).

 
devdoc/modules/register.txt · Last modified: 2008/11/19 07:26 by shketuljko
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki