Forum


Replies: 2   Views: 364
Adding lists using cloneblock
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 admin  · 23-11-2023 - 06:10

Hello,

cloneBlock does inline type replacements by default when using WordFragments (https://www.phpdocx.com/api-documentation/docx-path/clone-blocks-in-docx):

type string  Possible values are: inline (default) or block. Used by WordFragment values.

so block contents (such are paragraphs) are removed from the content, and only inline contents are added.
In this case you need to do a block type replacement to keep block and inline contents:

$docx->cloneBlock('SAMPLE', 1, $vars, array('removeBlockPlaceholder' => true, 'type' => 'block'));

We also recommend you create the new custom list style in the DOCX instead of the WordFragment, so it can be reused.

You can read more information about working with inline and block contents on https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml (Tricks and tips section).

Regards.