Create an ODT or ODS document template: Difference between revisions

Jump to navigation Jump to search
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 one of those locations:
* Create a file into the location:
'''htdocs/core/substitutions/functions_mymodule.lib.php''' or
'''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 valu is modified by your code and must be returned modified.
Warning: First parameter in function parameter declaration must start with & as value is modified by your code and must be returned modified.


Note: With 3.2 and higher, if you have build your own module (See page [[Module development]]), you can put the substitution file inside a subdirectory of this module called htdocs/mymodule/core/substitutions.
To have your substitution function be called, if you have to :
Moreover, function will be called only if module '''mymodule''' contains an entry  
* 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 module has been activated.
* 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).

Navigation menu