Replies: 1   Views: 3607
Variables bug?
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 wizzbit  · 24-01-2012 - 11:43

I have a problem using addTemplateVariable which gives me corrupt Word documents.

After trying a few things I tried this example:

$docx = new CreateDocx();
$docx->addTemplateImage('IMAGE', '../../Libraries/phpdocx_pro/examples/files/img/logo_phpdocx.gif');

This example works but the getTemplateVariables() gives strange results, it lists whole parts of text as a variable:
1: "/>We should first include a “placeholder” image with the properties we would like our “dynamical photo” to have: size, format, etcetera.Afterwords we should include the variable we want to parse with PHPDocX as an “alt text” for the image.If you do not know how to insert an alternative text for an image with Word the required steps are:Right click on the imageChoose “Size” from the context menuClick on the “Alternative text” tab of the popup windowFill the input text with, for example,
3: (although you may use any other variable name)In this case the PHPDocX method addTemplateImage(‘IMAGE’, ‘logo_php.gif’ ) searches for an existing image in the document with the alternative text ‘
5: ’ and replace it with logo_php.gif.In this example we will just include yet another photo of our logo .Best regards,The PHPDocX Team

I notes the same problem in another document, where I hade $HOTEL_IMAGE1$, $HOTEL_IMAGE2$ and $HOTEL_IMAGE3$
and getTemplateVariables returned:
1: "/>
3: "/>
5: "/>

Seems like some closing XML is added as Variable somehow?

I ran check.php and everything is OK