17
edits
| Line 33: | Line 33: | ||
* Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning). | * Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning). | ||
Your file descriptor for your module is ready. | Your file descriptor for your module is ready. | ||
=== Specific descriptor module for version 3.3 === | |||
With version 3.3 it will be possible to isolate the "specific" modules in a folder named '''custom'''. The objective of this approach will allow to separate third-party modules from standard modules (those who come from the full release of Dolibarr). | |||
The modules developed for all version of Dolibarr after the 3.2 should be able to be moved in a different folder than "htdocs", like "htdocs/custom", without having to modify the source code of the module . | |||
To make a module compatible with this principle requires that : | |||
* the pages making up the module must be able to read the file 'main.inc.php' whatever the root folder of the module; | |||
refer to the contents of the template file '''dev/skeletons/skeleton_page.php''' | |||
''Example :'' | |||
<source lang="php"> | |||
$res=0; | |||
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); // for root directory | |||
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // for level1 directory ("custom" directory) | |||
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); // for level2 directory | |||
if (! $res) die("Include of main fails"); | |||
</source> | |||
* the inclusion of classes dedicated to the module is done from the folder containing the php page; | |||
''Example :'' | |||
<source lang="php"> | |||
require_once 'class/myclass.php'; | |||
// Or | |||
require_once '../class/myclass.php'; | |||
</source> | |||
* The inclusion of classes from dolibarr use the following syntax; | |||
''Example :'' | |||
<source lang="php"> | |||
require_once DOL_DOCUMENT_ROOT.'/core/class/...'; | |||
</source> | |||
* '''conf/conf.php''' file must be modified as follows : | |||
remove comments before the definition of variables '''$ dolibarr_main_url_root_alt''' and '''$ dolibarr_main_document_root_alt''' then adjust the values to your configuration. | |||
''Example :'' | |||
<source lang="php"> | |||
$dolibarr_main_url_root_alt='http://localhost/dolibarr/custom'; | |||
$dolibarr_main_document_root_alt='/var/www/dolibarr/htdocs/custom'; | |||
</source> | |||
=== Test your descriptor === | === Test your descriptor === | ||
edits