Replies: 3   Views: 3208
Templates in tables
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 barek  · 21-03-2011 - 16:12

I'm trying to add several rows to a table using the provided examples like this:

[code] $docx->addTemplateVariable(
array (
array (
'VAR1' => 'row1 col1',
'VAR2' => 'row1 col2',
'VAR3' => 'row1 col3'
array (
'VAR1' => 'row2 col1',
'VAR2' => 'row2 col2',
'VAR3' => 'row2 col3'

However, since the table has a header, what happens is that the header is repeated over and over again.
Also, if I have less than three elements added, the template variables show up like this:

Header1 Header2 Header 3
Header1 Header2 Header 3
row1 col1 row1 col2 row1 col3
row2 col1 row2 col2 row2 col3
$VAR1$ $VAR2$ $VAR3$

Everything else (ordinary template variables etc) seem to be working perfectly.
Does anyone have a working example of this, and could tell me which PHP version etc. they are using? I'm using "PHP 5.2.4-2ubuntu5.14 with Suhosin-Patch"

Best regards,
Kristian Barek

Posted by admin  · 11-04-2013 - 12:12


You can check this feature in Template_header.php example.
This is the related code:

$settings = array(
'header' => true


'NAME' => 'Product A',
'WEIGHT' => '10',
'PRICE' => '5',
'NAME' => 'Product B',
'WEIGHT' => '20',
'PRICE' => '30',
'NAME' => 'Product C',
'WEIGHT' => '25',
'PRICE' => '7',


Posted by barek  · 11-04-2013 - 12:12

Thank you, this solved the problem, the $settings variable was not included in the example I got. :)