Hello,
Thank you very much for your files. You're right, there's a minor bug in the file that hasn't been detected until you have sent your files: a variable is not being initialized correctly. This issue only appears when there's more than one table with the same placeholder values.
Although it could be accomplished using DOCXPath or the MultiMerge classes without changing anything in the current version of the library, the dev team has generated a small patch that will be included in the next release of phpdocx.
As you are using the namespaces package (although the same line can be added to the classic package), please edit the Classes/Phpdocx/Create/CreateDocxFromTemplate.inc file and in line 886 add this line:
$tableCounter = 0;
Instead of this code:
foreach ($vars as $key => $rowValue) {
foreach ($foundNodes as $node) {
$domNode = dom_import_simplexml($node);
if (!is_object($referenceNode) || !$domNode->parentNode->isSameNode($parentNode)) {
$referenceNode = $domNode;
$parentNode = $domNode->parentNode;
$tableCounter++;
}
This is the correct code:
foreach ($vars as $key => $rowValue) {
$tableCounter = 0;
foreach ($foundNodes as $node) {
$domNode = dom_import_simplexml($node);
if (!is_object($referenceNode) || !$domNode->parentNode->isSameNode($parentNode)) {
$referenceNode = $domNode;
$parentNode = $domNode->parentNode;
$tableCounter++;
}
After this small fix you us the cloneBlock with tables using the replaceTableVariables method.
Our apologize for any inconvenience. This change is being fully tested to be added in the next stable release of the library.
Regards.