Triggers system: Difference between revisions

Jump to navigation Jump to search
Line 7: Line 7:
So, to add your own code that will be triggered by a Dolibarr trigger, this is the way to process:
So, to add your own code that will be triggered by a Dolibarr trigger, this is the way to process:


1) (only for Dolibarr >= v3.2.0) in your module config file for Dolibarr (eg: /core/modules/modMyModule.class.php), add triggers->1 in module_parts:
1) (only for Dolibarr >= v3.2.0) in your module descriptor file (eg: '''/mymodule/core/modules/modMyModule.class.php'''), add triggers->1 into module_parts array:
<source lang="php">
<source lang="php">
// Defined all module parts (triggers, login, substitutions, menus, etc...) (0=disable,1=enable)
// Defined all module parts (triggers, login, substitutions, menus, etc...) (0=disable,1=enable)
  $this->module_parts = array('triggers' => 1);
$this->module_parts = array('triggers' => 1);
  //$this->module_parts = array('triggers' => 1,
//$this->module_parts = array('triggers' => 1,
  //              'login' => 0,
//              'login' => 0,
  //              'substitutions' => 0,
//              'substitutions' => 0,
  //              'menus' => 0);
//              'menus' => 0);
</source>
</source>
Then disable and reenable your module. This will add a record into table llx_const to say Dolibarr a trigger file must be searched into module directory '''/mymodule/core/triggers/'''


 
2) Copy the trigger file '''htdocs/includes/triggers/interface_all_Demo.class.php''' under the new name:
2) Copy file '''htdocs/includes/triggers/interface_all_Demo.class.php''' under the new name:
* '''interface_all_''Xxx''.class.php'''
* '''interface_all_''Xxx''.class.php'''
or
or

Navigation menu