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.
When I am merging to templates in one, deleteTemplateBlock is longer working.
replaceVariableByText and replaceVariableByHTML work well.
Is it a limitation?
Hello,
After you do the merge with the MultiMerge class you just need to create a new phpdocx object with the template and use the deleteTemplateBlock method. There's no limitation.
We recommend you to open the merged DOCX to check if the block is correct.
Regards.
Thanks for your answer.
After merging, the resulting template is correct, but deleteTemplateBlock is not working.
In case I try to re-use the previous merging template and disable my merging condition, it is working : so the merged file is correct.
In summary, the deleteTemplateBlock function is not working only if I am using a template just merged.
Here is my code (PHPDocX version 4.5.1 BTW) :
if($this->getService()->getDisplayNotificationStatus()) {
$template = $outputPath.$folder.uniqid().'-'.$user->getId().'.docx';
$merge = new \Phpdocx\BatchProcessing\MultiMerge();
$merge->mergeDocx($templatePath.$templateName, array($templatePath.$notificationTemplateName), $template, array());
}
else {
$template = $templatePath.$templateName;
}
// Load template
$docx = new \Phpdocx\Create\CreateDocxFromTemplate($template);
// Manage charges texts blocks
if($deleteBlockA) {
$docx->deleteTemplateBlock('a_charge');
}
if($deleteBlockB) {
$docx->deleteTemplateBlock('b_charge');
}
if(deleteBlockC) {
$docx->deleteTemplateBlock('c_charge');
}
Hello,
We have done some tests and we see everything working fine. Please send to contact[at]phpdocx.com the most simple script that illustrates the issue and the DOCX you're merging. We need to run this script so please don't do external connections (such as databases and web services).
Regards.