Clone blocks

phpdocx includes several methods to work with block elements. These elements allow to define regions made of one or more contents in a DOCX, which can be cleaned of placeholders, deleted and cloned.

cloneBlock is a method that allows to clone all the content of a block. This method is available in Advanced and Premium licenses only.

For example, to clone the content of the region enclosed by the $BLOCK_TABLES$ placeholders, type this code:

When working with blocks and sub-blocks, cloneBlock includes the occurrence option to specify the block or sub-block based on the position:

Note that to call the cloneBlock method you have to write the placeholder identifier without neither the $BLOCK_ prefix (or any other custom block prefix using setTemplateBlockSymbol) nor the final $ symbol.