Forum


Replies: 3   Views: 4990
Nested data in add template variable
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 Ian Bibo  · 26-05-2014 - 08:31

Hello Everyone,



Thanks to the PHPDocX team for a wonderful product.



I have a question regarding the nesting of data in a table, (3 columns wide), which is in a Word template.  I cannot get it working the way I would like.  The issue: we have messages which are generated from a database query, if the message has replies, they are listed below the messge.



I have no problem looping through the replies and creating some text to add to the variable placeholders in the Word template, but the replies are made of three components: a name; the reply, and; a date.  When they are added to the Word template to create a table via the:

->addTemplateVariable(

$data,

'table',

$settings

)

function, each line of text, (paragraph), takes on the same formatting.



I would like each line of the reply to have differnet formatting if possible.  Each of the paragraphs / lines to be a different color.



Is there any way to do this, as I have tried, addText(), which added paragraphs above the table.  The createWordMLFragment fucntion did not work either.



Any help would greatly be appreciated.

Ian.


Posted by jorgelj  · 26-05-2014 - 09:24

Hello,



Using the addTemplateVariable method all rows will have the same style. Maybe you could create the table with HTML and replace a placeholder in the document; it's more complex but it's more flexible.



Regards.


Posted by Ian Bibo  · 26-05-2014 - 12:55

Hello jorgelj,



Tomorrow, I will have another go at using HTML tables and replacing a placeholder.  I was having limited success with that before hand, so moved back to the addTemplateVariable.



Thanks for you help, I appreciate it.



Ian.