-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with TemplateProcessor.php #2309
Comments
Hello, I think I have the same problem, when I use these functions in my code, the returned word file is corrupted. I have try your solution @Ervdu13, the file is no more corrupted but the replace didn't replace, same comportement as a delete Someone have a solution ? |
I have found a solution to avoid the problem, cloneBlock work correctly, so if you want to delete the block, just clone it to 0 like this : $templateProcessor->cloneBlock('myBlockName', 0, true); And for replace, you have to put a variable into your template like this :
And do this in your code : $templateProcessor->cloneBlock('myBlockName', 1, true, false);
$templateProcessor->setValue('myVar', <Your value here>); |
The functions "replaceBlock" and "deleteBlock" don't work.
in the function "replaceBlock" the preg_match isn't correct.
if I replace
'/(<?xml.)(<w:p.>${' . $blockname . '}</w:.?p>)(.)(<w:p.${/' . $blockname . '}</w:.?p>)/is'
by
'/(.((?s)<w:p\b(?:(?!<w:p\b).)?${' . $blockname . '}</w:.?p>))(.)((?s)<w:p\b(?:(?!<w:p\b).)[^$]?${/' . $blockname . '}</w:.?p>)/is'
(like in the function "cloneBlock"), the 2 functions are Ok
The text was updated successfully, but these errors were encountered: