Forum


Replies: 7   Views: 4016
Adding html to table symbol
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 darghon-blocked  · 21-12-2014 - 19:39

Hi all, Upto a few months back I was using a rather old version (2011 ish) of phpdocx, and now I had to update to the latest version (4.1) Since then, I've noticed it's no longer possible to add html code to a symbol in a table structure. I have an application where users gets a wysiwyg editor to enter comments. The document that is generated needs to list all those comments in a table form. (based on a template) Now the raw html code is shown in the document, instead of the formatted text. How do I fix this? I've already tried replacing the text with html code into wordfragments that are included instead, but that just leaves a blank line. Thanks for any help

Posted by admin  · 22-12-2014 - 09:27

Hello, What do you mean by 'to add html code to a symbol in a table structure'? Could you post a screenshot that shows what you need to do exactly? Regards.

Posted by darghon-blocked  · 22-12-2014 - 18:37

Hi This is a partial screenshot of the generated document: http://www.imghost.nl/download/Screenshot.png This should be styled content, not the way it is now.

Posted by admin  · 23-12-2014 - 07:46

Hello, Please check that Tidy is installed and running. What method are you using to replace the content? Regards.

Posted by darghon-blocked  · 08-02-2015 - 19:39

Hi, sorry for the very late reply, tidy is installed on the server. The code used to replace the symbols is added below. [code] foreach ($globaldata as $function => $variables) { $data = $variables['data']; $data = $this->_filterUnusedVariables($usedVariables, $data); foreach ($data as $target => $d) { if($target == 'image') { foreach($d as $key => $value) $docx->replacePlaceholderImage($key, $value); } else { if (isset($d[0]) && !empty($d[0])) { $docx->replaceTableVariable($d, ['target' => $target]); } if (!empty($d)) { $docx->replaceVariableByText(isset($d[0]) && !empty($d[0]) ? $d[0] : $d, ['target' => $target]); } } } } [/code] Probably more code than needed, but the "replaceTableVariable" function is used. Because it's repeated data

Posted by admin  · 09-02-2015 - 07:32

Hello, It looks like your tags are being escaped before replacing them. To check if the library works fine please run a simple script that adds the HTML with embedHtml, but writing the HTML in the script, not getting it from the WYSIWYG. Regards.

Posted by darghon-blocked  · 07-11-2015 - 06:32

Hi, I've had loads to do, so I couldn't pick this back up until a week ago.

A lot of new versions have been released in meanwhile, but I'll address the issue more clearly now.

Users of my application add comments in a wysiwyg editor. These comments can be preformatted to contain tables, highlighting, pretty much "structured" content.

I'm attempting to generate a document listing several of those structured comments.

Meaning I have a table which lists those values.

The code gets the html value of the content, and passes it to the function "replaceTableVariable".

Reading through the code there, I understand why no html is added, because it created a simple xml node of the tablerow, and "blindlly" replaces the symbol with the content. which is than added before the original symbol row. (insertBeforeNode)

Is there any fix around this?

 

Thank you

Posted by admin  · 08-11-2015 - 12:08

Hello,

The method replaceTableVariable doesn't allow to add HTML. We recommend you to do it in two steps: first use replaceTableVariable to add as many rows as needed setting new placeholders and save the document; and then open this new DOCX and use the replaceVariablebyHTMLmethod to replace the placeholders by HTML.

Regards.