31,026
edits
| Line 94: | Line 94: | ||
=== Other personalized tags === | === Other personalized tags === | ||
If you want to add a field that is not predefined, this is the solution: | If you want to add a field that is not predefined, this is the solution: | ||
* Create a file into | * Create a file into the location: | ||
'''htdocs/mymodule/core/substitutions/functions_mymodule.lib.php''' | '''htdocs/mymodule/core/substitutions/functions_mymodule.lib.php''' | ||
* Inside this file, just write one function like this: | * Inside this file, just write one function like this: | ||
| Line 119: | Line 118: | ||
Function will be called before generating document to complete the array used for substitution and to replace tag myowntag with value $myvalue. You can add as many tags as you need and put all personalized code you want to define values (search into database, into files, calculation, from received parameters or from global variables)... | Function will be called before generating document to complete the array used for substitution and to replace tag myowntag with value $myvalue. You can add as many tags as you need and put all personalized code you want to define values (search into database, into files, calculation, from received parameters or from global variables)... | ||
Warning: First parameter in function parameter declaration must start with & as | Warning: First parameter in function parameter declaration must start with & as value is modified by your code and must be returned modified. | ||
To have your substitution function be called, if you have to : | |||
* Check your substitution file is inside subdirectory module called htdocs/mymodule/core/substitutions. | |||
* Build your own module (See page [[Module development]]) with its descriptor file. | |||
* Check your module descriptor file contains an entry to declare this module has a substitutions file | |||
<source lang="php"> | <source lang="php"> | ||
$this->module_parts = array('substitutions' => 1) | $this->module_parts = array('substitutions' => 1) | ||
</source> | </source> | ||
and | * Enable your module (module must be enabled and disabled each time you change the descriptor). | ||
Note2: this only allows to define global, static ODT variables (ie: to make dynamic variables that changes for every line of product, please see the next chapter). | Note2: this only allows to define global, static ODT variables (ie: to make dynamic variables that changes for every line of product, please see the next chapter). | ||