Creating User Defined ODT Tags

Hello
I am just curious to know if anyone has developed their own tagline to be used in ODT Template. I figured out way to fetch data directly from SQL Database. However defining a tag for this process and adding it to the other tags looks complicated. The reality is, I havent yet located the PHP script for this tag lines. Anyone who has experince with this and could share an example file would be really helpful

Thank You

Hello,
I’ve done it for use with a specific database.
I defined a custom module. I have defined in this module :
a mymodule.class.php in core/class in which I declared my own class. For me, this class extends Societe class. it stores the fields I add to ODT. This class has a fetch_mydata function which have the sql requests and populate the fields I need. This function takes a parameter for the SQL requests.
I have duplicated htdocs/societe/soc.php in custom/mymodule/doc/doc.php and altered it to include a /custom/mymodule/core/modules/html.formfile_ip.class.php. In this doc.php, I call fetch_mydata and the function thirdparty_doc_create($db, $mydata, ‘’, GETPOST(‘model’,‘alpha’), $outputlangs);
I have also created a core/substitutions/function_mymodule.lib.php which defines a function mymodule_completesubstitutionarray(&$substitutionarray,$langs,$mydata)
It is said that

mymodule_completesubstitutionarray defines $substitutionarray[‘subst_key’] where subst_key can be used in ODT as {{subst_key}}

Hi,

Please see : https://wiki.dolibarr.org/index.php/Create_an_ODT_document_template
The chapter on Other personalized tags

Came to know about the User Defined Tags option, because I visited the above page. Just looking for help from Experts who encountered this case and has solved successfully