Forum


Replies: 1   Views: 3253
Render html in a table cell with addtemplatevariable
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 atch  · 05-02-2013 - 17:40

I have a repeating datastructure :

$table = array();
$table[] = array('Some label', '<div>some html, mainly list items</div>');
$table[] = array('Some label2', '<div>some html2, mainly list items</div>');


If build the table the following way :

$html = '<div>some html, mainly list items</div>';
$field_html = $docx->embedHTML($html, array('isFile' => false, 'rawWordML' => TRUE));
$table_html = $docx->createWordMLFragment(array($field_html));

$table = array();
$table_settings = array(
'header' => FALSE,
'html' => FALSE,
'rawWordML' => FALSE
);

$table[] = array('VAR_SYS_LABEL' => $label, 'VAR_SYS_VALUE' => $table_html);


Without a template this works just fine :

$docx->addTable($table, $table_settings);


However I need to use a template for styling reasons.

In my template I have a table with the following parameters : $VAR_SYS_LABEL$ | $VAR_SYS_VALUE$

$docx->addTemplateVariable($table, 'table', $table_settings);

The table is rendered correctly but the html is replaced with WordML code instead of HTML

Any ideas ?