Forum


Replies: 4   Views: 1040
Bulkprocessing replace all variables in the same text tag
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 admin  · 09-11-2021 - 18:28

Hello,

Thanks for the detailed post about your issue. Yes, as your code illustrates, the current version of BulkProcessing (class available only in Premium licenses) doesn't allow changing two placeholders in the same w:t tag. Template methods included in CreateDocxFromTemplate such as replaceVariableByText don't have this limitation.

We have moved your update to the dev team to be added in the stable release of phpdocx (adding $xpath->registerNamespace ):

$dom = $this->generateDomDocument($dom->saveXML());
$xpath = new DOMXPath($dom);
$xpath->registerNamespace('w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');

 The code you have added is the best approach to refresh the DOMDocument contents and get other placeholders in the same w:t tag that need to be replaced too.

Regards.