Forum


Replies: 3   Views: 3637
Bugs in addtemplate function
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 r2363c  · 21-10-2013 - 13:16

Hi



It may be a bit late, but we encountered the same problem. While assigning a 1 element array to a template variable templates placeholder were repeated when in a table. The problem was still present in 3.2 and 3.3 version.



To overcome this first test if array count is greater than 1 (1 element). If only one element in  your array, just assign the string variable of the array ($yourarray[0]) to your variable :




$replacedata = explode("\n",$maybemultilinedata);

$docx->addTemplateVariable($var,(count($replacedata )>1) ? $replacedata :$replacedata [0]);


regards



r2363c / altidev team/ jca