Create an ODT or ODS document template: Difference between revisions

Jump to navigation Jump to search
Line 111: Line 111:
=== 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:
* First create a new module descriptor file. See page [[Module development]] for this.
* Add a file into htdocs/includes/modules/substitutions/functions_mymodule.lib.php
* Add a file into htdocs/includes/modules/substitutions/functions_mymodule.lib.php
* Inside this file, just write one function like this:
* Inside this file, just write one function like this:
Line 135: Line 134:
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. Moreover, function will be called only if module '''mymodule''', created at first step, has been activated.
Warning: First parameter in function parameter declaration must start with & as valu 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.
Moreover, function will be called only if module '''mymodule''' contains an entry $this->module_parts = array('substitutions' => 1) and module has been activated.


== Store your document ==
== Store your document ==
To have your document to appear in list of available documents, put it into correct subdirectory found into
To have your document to appear in list of available documents, put it into correct subdirectory found into
directory '''documents/doctemplates'''
directory '''documents/doctemplates'''

Navigation menu