Create an ODT or ODS document template: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
Tag: 2017 source edit
mNo edit summary
Tag: 2017 source edit
Line 147: Line 147:
*Check your module descriptor file contains an entry to declare this module has a substitutions file
*Check your module descriptor file contains an entry to declare this module has a substitutions file


<source lang="php">
<syntaxHighlight lang="php">
$this->module_parts = array('substitutions' => 1)  
$this->module_parts = array('substitutions' => 1)  
</source>
</syntaxHighlight>


*Enable your module (module must be enabled and disabled each time you change the descriptor).
*Enable your module (module must be enabled and disabled each time you change the descriptor).
Line 164: Line 164:
*Here are the twists: in the file, write another function with almost the same name but with '_lines' appended, and also add a new $lines variable:
*Here are the twists: in the file, write another function with almost the same name but with '_lines' appended, and also add a new $lines variable:


<source lang="php">
<syntaxHighlight lang="php">
/** Function called to complete substitution array for lines (before generating on ODT, or a personalized email)
/** Function called to complete substitution array for lines (before generating on ODT, or a personalized email)
  * functions xxx_completesubstitutionarray_lines are called by make_substitutions() if file
  * functions xxx_completesubstitutionarray_lines are called by make_substitutions() if file
Line 182: Line 182:
   $substitutionarray['myowntag']=$myvalue;
   $substitutionarray['myowntag']=$myvalue;
}
}
</source>
</syntaxHighlight>


Contrary to the previous function which was called only once, this function will be called everytime a line of product will be processed, giving you each time a new $line object that you can process. This allows you to do different substitutions for each product.
Contrary to the previous function which was called only once, this function will be called everytime a line of product will be processed, giving you each time a new $line object that you can process. This allows you to do different substitutions for each product.

Navigation menu