Forum


Replies: 1   Views: 1261
Gettemplatevariables
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by hotspot22  · 21-05-2021 - 09:37

Hi!

I'm using phpdocx 9.5 premium for working with block placeholders in a docx document. There are some block placeholders defined and I remove some of them with deleteTemplateBlock() what's working fine.

To clear the remaining placeholders and keep their inner content I wanted to use getTemplateVariables() to get the placeholder names and remove them with removeTemplateVariable().

But I have the problem that no template variables are returned. Instead I'm getting this:

array(2) {
  ["document"]=>
  array(52) {
    [0]=>
    string(80) "10;90jcwfIWJU67QAgl6YK0S0CoHGBkTxKLZGx5TGhvj5O2G0SRWNoz/78nu9wcxkFMGNg6quQqL6RA&"
    [1]=>
    string(80) "10;OlTrorhX2lFEilmcO2RdNtjC5xDF9pCuTyYBB5bi6bQ4syoJ3g9WQ0ymaiLzg5KdCXlKLjvcW893&"
    [2]=>
    string(80) "10;JsXecLq0q+WD6m8AAAD//wMAUEsDBBQABgAIAAAAIQA4/SH/1gAAAJQBAAALAAAAX3JlbHMvLnJl&"
    [3]=>
    string(80) "10;JVI2sOt6UJgd+ZiDgffL8ekFlFSbvV0oo4EbChzGx4f9GRdb25HMsYhqlCwG5lrLq9biZkxWOiqY&"
    [4]=> ...
  ...
  }
...
}

 

I've tried the example script with the example document what's working correctly. But using my own document does not work. Removing blocks is working, so there should be no problem to identify the blocks/variables.

Any ideas?

Posted by admin  · 21-05-2021 - 10:10

Hello,

Maybe the symbol you are using to wrap placeholders is being used in other contents of the DOCX, so the existing placeholders can't be returned correctly. We recommend using a symbol that is not used in other contents of the documents to wrap placeholders: setTemplateSymbol. Since phpdocx 11, ${ } can also be used to wrap placeholders too: ${VAR}

Please send to contact[at]phpdocx.com the template and the username or email of the user that purchased the license you are using.

Regards.