Add block placeholders

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.

To define blocks in a DOCX, create two placeholders with the same name, at the beginning and the end of the region, with the following syntaxis:


As you can see, blocks keep the same syntaxis as any other phpdocx placeholder. You can choose any symbol to enclose it. The dollar symbol ($) is the default one. You are free to write any identifier too, as long as you keep BLOCK_ as the initial string (or any other custom block prefix using setTemplateBlockSymbol).

For example, you could create this content in a template:

Notice how the $BLOCK_DATA$ placeholders delimit the region.