Forum


Replies: 3   Views: 1547
Clone block
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 Nurlybek  · 05-02-2019 - 09:28

Hello, i want to use cloneBlock with table in content. My table have 2 column and 13 rows. And first and 8th row merged column. So, when i clone block, in result i have wrong table, some rows removed and merged with previows.

Template: https://imgur.com/IJbXxF1

Result: https://imgur.com/CiGt7aG

Code: https://imgur.com/Ida6ExS

Posted by admin  · 05-02-2019 - 09:35

Hello,

To clone a single content such as a table, we recommend using the cloneWordContent method (https://www.phpdocx.com/api-documentation/docx-path/clone-elements-in-docx). And use the cloneBlock to clone more than one content.

Anyway, it should work correctly. Please send to contact[at]phpdocx.com the template and we'll do some quick tests.

Regards.

Posted by Nurlybek  · 05-02-2019 - 10:07

Thank you, cloneWordContent work fine

Posted by admin  · 05-02-2019 - 10:32

Hello,

Although the cloneWordContent method works correctly, we have checked your template.

The problem is that the block wrappers are using the same symbol than some contents in the element to be cloned ($), and these contents have the same words than the block name (PART INST).
 
We recommend you to use a unique symbol to set block placeholders:
 
$docx->setTemplateSymbol('#');

$docx->cloneBlock('PART_INST');

$docx->setTemplateSymbol('$');

or use unique placeholder names for blocks.

Regards.