Forum


Replies: 3   Views: 1507
Clone blocks does not work if block name is split between to tags
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 ralfjahr  · 05-01-2021 - 10:21

Hi all,

unfortunately, we have the issue that template blocks get split between two tags somehow and do not work anymore.

<w:r w:rsidRPr="00BB5E6A">
<w:rPr>
<w:rFonts w:cstheme="minorHAnsi"/>
<w:color w:val="000000" w:themeColor="text1"/>
<w:sz w:val="16"/>
<w:szCs w:val="6"/>
</w:rPr>
<w:t>$BLOCK</w:t>
</w:r>


<w:r>


<w:rPr>

<w:rFonts w:cstheme="minorHAnsi"/>

<w:color w:val="000000" w:themeColor="text1"/>

<w:sz w:val="16"/>

<w:szCs w:val="6"/>

</w:rPr>

<w:t>_ACCOUNT$</w:t>

</w:r>

</w:p>

In the example above, the block is split and we cannot clone it anymore.

Below is an example which works.

<w:p w:rsidP="001C7351" w:rsidRDefault="00517B3D" w:rsidRPr="001C7351" w:rsidR="00BB5E6A" w14:textId="129ABE70" w14:paraId="69229FF2">


<w:r>

<w:t>$BLOCK_CONTACT$</w:t>

</w:r>

</w:p>

How can this be prevented?

This seems to happen without making any changes to any block variable.

Thanks! 

Posted by admin  · 05-01-2021 - 10:33

Hello,

What version of phpdocx are you using? phpdocx handles that broken tags automatically for placeholders; old versions of phpdocx may require cleaning the variables before calling cloneBlock (https://www.phpdocx.com/api-documentation/templates/proccess-a-word-docx-template):

$docx->processTemplate();

Latest releases include the same code embedded in the cloneBlock method. Other template methods include it too.

Regards.

Posted by ralfjahr  · 08-01-2021 - 09:47

We still use phpdocx 9. Thank you, your response was perfect. Best, Ralf