Forum


Replies: 2   Views: 2621
Print out blank rather than $var$
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 maxelcat  · 30-01-2018 - 16:18

Hi

I have a simple table template with four columns. In some cases there is no data for the last two columns and partial data in the first two. I am creating an array ($tabledata) that holds arrays of data - so that one line might be like this Array ( [SUB] => Number [AB0] => M8b ) - its subject/grade data.

The first two columns are fine- where there is no data I am getting a blank. However, in the last two columns I get the variable names (like $AB2$ ) printing out into every square.

Is there someway to tell phpdocx not to print out these values from the template when using $docx->replaceTableVariable($tabledata)

Many thanks


E

Posted by admin  · 30-01-2018 - 18:32

Hello,

We recommend you to set values for all placeholders. You can set an empty blank space or a WordFragment with an empty paragraph when you don't want to set a value.

Or you can replace the placeholders and then use the removeTemplateVariable to remove the remaining ones. If you don't know the name of the remaining placeholders you can use the getTemplateVariables method.

Regards.

Posted by maxelcat  · 13-03-2018 - 12:11

Thanks - that's very helpful!