31,003
edits
| Line 200: | Line 200: | ||
<source lang="php"> | <source lang="php"> | ||
$res=0; | $res=0; | ||
if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); // | if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); // to work if your module directory is into dolibarr root htdocs directory | ||
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // | if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // to work if your module directory is into a subdir of root htdocs directory | ||
if (! $res) die("Include of main fails"); | if (! $res) die("Include of main fails"); | ||
</source> | </source> | ||
Note that you may add more "../" depending on the depth of the file relative to your module directory tree. | |||
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. | 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, so this rule must be applied by all modules. | ||
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: | ||