Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
Hi Folks,
I just finished my first project and wonder how I might approach things more efficiently next time.
In addition to using simple variable replacements from a template doc, I need to handle more complex substations based on logic. For example, based on the value of a particular data field, I might need to insert 1 paragraph or 2 paragraphs or 1 table or another table.
Using the function ReplaceVariableByText is limited to basic substitution.
What is the general approach to insert formatted content into a template document? Here is what I considered...
1) Have completely separate templates, one for each variation. This isn't very elegant, but it is straightforward. Gets ugly if the template has multiple subsitutions.
2) Cut the document into template sections. Keep variations in different sections. Perform ReplaceVariableByText as needed and merge the docx together.
3) Cut the document into template sections but create variable content using docxCreate features.
I ended up using method #1 above to get the job done, but want to know how to improve the process next time.
One option that I wouldn't consider is to create the document from scratch using createdocx. This particular project had 10 4-page contracts for each client and only 3 days to create them. Future turnaround will be similar. The contract body could change substantially. Plus, they only execute once per year.
So, how do you approach this challenge?
Thanks
Jonathan