Changes

Jump to navigation Jump to search
Line 229: Line 229:  
if (! $res) die("Include of main fails");
 
if (! $res) die("Include of main fails");
 
</source>
 
</source>
 +
As you can see, there si several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the "custom" directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.
 +
 
Note that you may add more "../" depending on the depth of the file relative to your module directory tree.
 
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, 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:

Navigation menu