31,014
edits
| Line 197: | Line 197: | ||
Copy, into that directory, the file '''skeletons_page.php''' that will serve as a starting point for your page file. | Copy, into that directory, the file '''skeletons_page.php''' that will serve as a starting point for your page file. | ||
Edit the file to have a correct relative path to the main.inc.php file. | Edit the file to have a correct relative path to the main.inc.php file. | ||
<source lang="php"> | <source lang="php"> | ||
include("../../main.inc.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> | </source> | ||
This depends on the depth of the directory in which the file is (Add or remove "../"). | This depends on the depth of the directory in which the file is (Add or remove "../"). | ||
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, that's why we make several includes. | |||
It's in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file: | It's in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file: | ||
| Line 210: | Line 216: | ||
Then enter your code to display the page. | Then enter your code to display the page. | ||
* The inclusion of a class dedicated to the module is done using a Dolibarr function (and not using directly include_once); | |||
''Example :'' | |||
<source lang="php"> | |||
dol_include_once('/mymodule/class/myclass.class.php', 'MyClass'); | |||
</source> | |||
* The inclusion of classes from dolibarr use the following syntax (module to core or core to core); | |||
''Example :'' | |||
<source lang="php"> | |||
if (! class_exists('DoliClass')) require DOL_DOCUMENT_ROOT.'/core/class/doli.class.php'; | |||
</source> | |||
=== Replace templated parts of screen (version 3.3+) === | === Replace templated parts of screen (version 3.3+) === | ||