Replies: 1   Views: 3458
Repeating sections in a template
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.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by anch  · 14-05-2012 - 22:22

I have two templates — a main template which has the document header and another which I want to repeat multiple times within the main template for different data.

I couldn't find an existing method to do this, so this was my solution:
1) Create temporary documents from the second template for every set of repeating data
2) In my main template I have a variable $SECTIONS$ which I replace with a list of variables — $SECTION1$ $SECTION2$ $SECTION3$... etc.
3) Replace each $SECTIONn$ variable in the main document with its respective temporary document from step 1.

This works fine for documents that don't have a lot of repeating data, but for larger documents it isn't practical to create several hundred temporary documents.

Is there another way to accomplish this?