How to use personalized tags with ODT template

Hello,

I want to use personalized tags with ODT template for the default modules :
- propal (proposal)
- commande (order)
- facture (invoice)

For that, i have followed the tutorial available here

I have created this file :

htdocs/core/substitutions/functions_mymodule.lib.php

with this code :

/** 		Function called to complete substitution array (before generating on ODT, or a personalized email)
 * 		functions xxx_completesubstitutionarray are called by make_substitutions() if file
 * 		is inside directory htdocs/core/substitutions
 * 
 *		@param	array		$substitutionarray	Array with substitution key=>val
 *		@param	Translate	$langs			Output langs
 *		@param	Object		$object			Object to use to get values
 * 		@return	void					The entry parameter $substitutionarray is modified
 */
function mymodule_completesubstitutionarray(&$substitutionarray,$langs,$object)
{
   global $conf,$db;
 
   $myvalue='Put here calculated value to insert';
   $substitutionarray['myowntag']=$myvalue;
}

And when i am testing in debug if it’s work, my debugger does’nt stop in the function.

And if am looking in the file :

functions.lib.php

the function :

function complete_substitutions_array(&$substitutionarray,$outputlangs,$object='',$parameters=null,$callfunc="completesubstitutionarray")

with a breakpoint, the array

$conf->modules_parts['substitutions']

still always empty.

If a someone have an idea, this will be greatfull.

I am using dolibarr 3.3.1

Thank’s for your help

After much of research and test, i have found a solution :woohoo:
but i don’t know if it’s a good one :confused:

My purpose is to add personalized tags in my odt template when i ma using standard module like :
- proposal
- order
- invoice

WHen i am reading the document, i have understood that i have just had my functions_mymodule.lib.php file in the directory :

htdocs/core/substitutions/

but it is not working :unhappy:

Well, i am taking my courage with my 2 hands, and my solution is the next :

I don’t want create a module, but after analysis, i have saw in the file htdocs/core/class/conf.class.php how the system add a new substitions in this function :

This function create a query ofr the table

llx_const

and if a name of module has the word

SUBSTITUTIONS

at his end, the system add the substitutions directory.

Well, i have created a new directory with the good structure, and i have added a new key in this table :

MAIN_MODULE_MYMODULE_SUBSTITUTIONS

and now, when i put a breakpoint, the debugger stop in my function.

I don’t know if it is the good solution for add personalized tags for the standard module.
If you have an other tips, i am would to test ^^

Thank’s for your help