TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Read Variables from Docx

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Guido
Date: 2015-09-10
Time: 02:28

Read Variables from Docx

Hallo
I use TBS with OpenTBS and want read the Placeholder -> [MyPlaceholder] from the Template.docx before i Merge. Is this posible?

Kind Regards
Guido
By: Skrol29
Date: 2015-09-15
Time: 00:18

Re: Read Variables from Docx

Hi,

What do you mean by « read the Placeholder » ?
By: Guido
Date: 2015-09-15
Time: 00:28

Re: Read Variables from Docx

I want to know witch Placeholders are used in the Document.

Regards
Guido
By: Skrol29
Date: 2015-09-15
Time: 09:21

Re: Read Variables from Docx

TBS can search placeholders only by their name.
"[MyPlaceholder]" can be a normal text in the template, or can be a TBS field as well.
This placeholder will be merged only if you call $TBS->MergeField('MyPlaceholder', ...) or $TBS->MergeBlock('MyPlaceholder', ...)

That's why TBS gives no feature to find possible placeholders in the template.
Nevertheless, you can code your own small function to find your placeholders. For example if you know that in your template figures like "[*]" are reserved to TBS fields then you can search those figures. The TBS current template contents can be retrieve with $TBS->Source.

By: Sheepy
Date: 2015-09-16
Time: 06:29

Re: Read Variables from Docx

Assume that I can have this text "[o]=[o]".  I can merge it as two fields called "o", or I can merge it as one field called "o]=[o".  Which should I report?

Only you know what placeholders exist in a template; TBS doesn't.
(If you don't know, ask someone who does.)