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) Copy the trigger file '''htdocs/core/triggers/interface_all_Demo.class.php''' under the new name:
+
1) Copy the trigger file '''htdocs/core/triggers/interface_20_all_Demo.class.php''' under the new name:
−
* '''interface_all_''Xxx''.class.php'''
+
* '''interface_99_all_''Xxx''.class.php'''
or
or
−
* '''interface_mod''MyModule_Xxx''.class.php'''
+
* '''interface_99_mod''MyModule_Xxx''.class.php'''
where ''Xxx'' is a string of your choice startint with uppercase character and ''MyModule'' is the name of a module if you want that trigger is activated only if module MyModyle is activated. If you want the trigger to be always active, use ''all'' instead of modMyModule.
where ''Xxx'' is a string of your choice startint with uppercase character and ''MyModule'' is the name of a module if you want that trigger is activated only if module MyModyle is activated. If you want the trigger to be always active, use ''all'' instead of modMyModule.
This new file must be saved inside same directory.
This new file must be saved inside same directory.
Line 17:
Line 17:
For example, you can name your new trigger file:
For example, you can name your new trigger file:
−
''htdocs/includes/triggers/interface_modFacture_Myworkflow.class.php''
+
''htdocs/includes/triggers/interface_99_modFacture_Myworkflow.class.php''
By creating such a file with name as in the example, your new trigger file will be executed each time a Dolibarr business event occurs but only if the module Facture is enabled.
By creating such a file with name as in the example, your new trigger file will be executed each time a Dolibarr business event occurs but only if the module Facture is enabled.
−
'''Note''': Before Dolibarr 3.2, you have to place triggers inside the '''includes/triggers/''' folder instead of '''core/triggers/''' (eg: htdocs/includes/triggers/interface_modMyModule_Xxx.class.php).
+
'''Note''': With Dolibarr 3.2+, you can also place the triggers in your own module's subdirectly. Eg: if your module resides in htdocs/mymodule/, then you can place your triggers inside htdocs/mymodule/core/triggers/. But for this, you must declare the trigger into your module descriptor file (eg: '''/mymodule/core/modules/modMyModule.class.php'''). For this, add into this file triggers->1 into module_parts array:
−
−
'''Note2''': With Dolibarr 3.2+, you can also place the triggers in your own module's subdirectly. Eg: if your module resides in htdocs/mymodule/, then you can place your triggers inside htdocs/mymodule/core/triggers/. But for this, you must declare the trigger into your module descriptor file (eg: '''/mymodule/core/modules/modMyModule.class.php'''). For this, add into this file 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)
Line 35:
Line 33:
−
2) Edit the file ''interface_modMyModule_Myworkflow.class.php'' to rename class ''InterfaceDemo'' by ''InterfaceMyworkflow''
+
2) Edit the file ''interface_99_modMyModule_Myworkflow.class.php'' to rename class ''InterfaceDemo'' by ''InterfaceMyworkflow''
Then go on page Home-> System Infos -> Dolibarr -> Triggers.
Then go on page Home-> System Infos -> Dolibarr -> Triggers.