cloneBlock
- addBibliography
- addBookmark
- addBreak
- addChart
- addCitation
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOLE
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addSVG
- addTab
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordFragment
- addWordML
- embedHTML
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createDocx
- createDocxAndDownload
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importChartStyle
- importHeadersAndFooters
- importListStyle
- importStyles
- importStylesWordDefault
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDecimalSymbol
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- setRTL
- clearBlocks
- cloneBlock
- deleteBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- removeTemplateVariableImage
- replaceBlock
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
- tickCheckboxes
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
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.