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,
replacing a variableByTest does not work in some cases, the getFromZip method returns FALSE because, it seems, something's wrong with the word/header1.xml occurrence of the XPath. There is, for example,
$xpathFooters = simplexml_import_dom($this->_contentTypeT);
$xpathFooters->registerXPathNamespace('ns', 'http://schemas.openxmlformats.org/package/2006/content-types');
$xpathFootersResults = $xpathFooters->xpath('ns:Override[@ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml"]');
foreach ($xpathFootersResults as $footersResults) {
$footer = substr($footersResults['PartName'], 1);
$loadContent = $this->getFromZip($footer);
…
This $loadContent becomes FALSE and the subsequent code crashes because of that.
$footer is "word/footer1.xml", $this->getFromZip returns FALSE because $XMLData = $zip->getFromName($src); already returns FALSE.
Any ideas how to resolve this?
Hi,
Please send to contact[at]phpdocx.com the DOCX, we'd like to check it.
Regards.
For the (our) record, the error occurs when working in header or footer target and using *subsequent* invocations of replaceVariableByText, just like
$docx->replaceVariableByText(array('one' => 'ONE REPLACED'),
array('target' => 'footer'));
$docx->replaceVariableByText(array('another' => 'ANOTHER REPLACED'),
array('target' => 'footer'));
"Merging" the replacement array and using only one invocation would work.
Hello,
We have done some tests with your script and template and it's working fine on our test servers.
Regards.