
An oft underestimated feature of LiveDocx is support for the Microsoft Word INCLUDETEXT field type, which allows templates to be chained together into one larger template. The entire contents of the sub-templates are brought into the main template in the order in which the fields are inserted, during the merge process. The final document contains the contents of the template and all sub-templates.
To learn more about INCLUDETEXT and how to insert INCLUDETEXT fields into your template, please take a look the following articles:
- WD2000: How to Create a Long Document in Word, Section IncludeText Field
Zend\Service\LiveDocx\MailMerge provides two methods to control how or whether sub-templates are included in the main template.
In the default state, all templates, which are referenced in INCLUDETEXT fields are included during the merge process.
If you do not want this to be the case, the method setIgnoreSubTemplates() can be set to true. This disables the inclusion of all sub-templates during the merge process. Using the free public LiveDocx service, you cannot selectively define which templates should be included. It is an all-or-nothing approach.
The premium and licensed versions of the LiveDocx service, on the other hand, allow for more fine grained control. These versions provide the method setSubTemplateIgnoreList(), which takes an array of filenames that should not be included. This way, you can, for example, included sub-templates 2 and 5, but not 1, 3 and 4.
The methods setIgnoreSubTemplates() and setSubTemplateIgnoreList() will be part of Zend Framework 2 when it ships. The latest code updates should be merged into master on the Zend canonical repository within the next few weeks. For the time being, the code is still in my GitHub repository, in the branch livedocx-2.0.
You can clone the latest code at:
https://github.com/jonathanmaron/zf2/tree/livedocx-2.0
Take a look at the following directory for some demonstration applications that illustrate the methods setIgnoreSubTemplates() and setSubTemplateIgnoreList()
/demos/Zend/Service/LiveDocx/MailMerge/templates-ignore/
Feel free to contact me, using the comments section below, if you need any help, or notice any inconsistencies in the code.
June 10, 2011: The code updates mentioned in this post have now been merged into master on the Zend canonical repository.