cloneBlock

cloneBlock

ADVANCED / PREMIUM TRIAL

Clones a block in the document.

Description
public cloneBlock (string $blockName [, int $occurrence [, array $variablesBlock = array() [, array $options = array()]]])

Block placeholders must be added in their own paragraph.

Parameters

blockName

The block var.

occurrence

Position of the block to be cloned. 1 as default.

variablesBlock

This must be an array with the names of the placeholder block variables as keys and the plain text or WordFragment that should replace them as values.

The subarray 'images' can be added to do image replacements.

options

The possible keys and values of this array are:

Key Type Description
removeBlockPlaceholder bool False as default. If true, remove block placeholders from the cloned content.
type string Possible values are: inline (default) or block. Used by WordFragment values.
Exceptions

Method not available.

Code samples

Example #1

The resulting Word document looks like:

Example #2

The resulting Word document looks like:

Example #3

The resulting Word document looks like:

Release notes
  • phpdocx 14.0:
    • generate new id and name attributes for drawing object non-visual property tags.
  • phpdocx 13.5:
    • improved using block placeholders with parent elements.
    • replace image placeholders.
  • phpdocx 12.5:
    • clone the same block multiple times.
    • add and replace text placeholders with text strings or WordFragments.
  • phpdocx 8.2:
    • block placeholders in templates don't need to be unique.
  • phpdocx 7.0:
    • new method.