getTemplateVariablesType

getTemplateVariablesType

ADVANCED / PREMIUM TRIAL

Returns the template placeholder variables and their types.

Description
public getTemplateVariablesType ()

This method returns all phpdocx placeholder variables of the current template and their types.

In order to work properly with this method, it is recommended not to use the symbol chosen for delimiting the placeholders in other contents of the document. It is preferable to have a unique symbol in the document or ${} for placeholders.

The parseMode option can be enabled in CreateDocxFromTemplate to get template placeholders. The parse mode is slower than the default one, but it's more accurate when the template includes placeholder symbols as regular contents.

A placeholder may have more than one type. For example, in a list, a placeholder that is not an image will be of the "text" and "list" types.

Return values

Array with the template variables and their types (text, table, list, image) included in the Word template.

Exceptions

Method not available.

Code samples

Example #1

The resulting output looks like:

Example #2

Release notes
  • phpdocx 13.5:
    • new method.