Cookbook
- Learn phpdocx in 5 minutes
- Tutorial
- API quick guide
- HTML to Word
- HTML Extended
- Conversion plugin
- Word to HTML
- DOCXPath
- Bulk processing
- DOCXCustomizer
- Digital signature
- Cryptophpdocx
- Right to left languages
- phpdocx CLI command
- Tracking
- Artificial Intelligence
- Blockchain for documents
- JavaScript API
- Compiled mode
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:
$BLOCK_*$
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: