Using Xoops API
In addition to the Xoops API documentation http://www.xoops.org/misc/api/ here we also need guidelines for module writers as to what classes to use when, why, and how, etc. For example:
* XoopsObject Data Access classes
If you create a module class (in the class folder of your module) called <Module>MyClass that extends XoopsObject:
include_once XOOPS_ROOT_PATH."/class/xoopsobject.php";
class ModuleMyClass extends XoopsObject
{
/**
* Constructor
**/
function ModuleMyClass() // Constructor
{
$this->initVar('my_variable', XOBJ_DTYPE_INT, NULL);
}
}
and a handler called <Module>MyClassHandler that extends XoopsObjectHandler:
class ModuleMyClassHandler extends XoopsObjectHandler
{
}
you can then obtain a refereance to an instance the handler class like so:
In /modules/module/index.php:
$myclasshandler = &xoops_getmodulehandler('MyClass');
Built in data object handlers can be obtained via xoops_gethandler('<class>').
Search for the use of this idiom in other modules for an idea of how these classes let you build data access objects to interface with corresponding database tables.
Also see these wiki pages: XoopsObject | XoopsObjectHandler
Back to the Main Page

![[Main Page]](/modules/mediawiki/images/mediawiki.png)






