Forum


Replies: 2   Views: 3362
Embedhtml: lists & <p> tags not rendering on templates?
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 coconnor  · 18-12-2016 - 18:40

Hello-

Running into an odd issue. I'm attemping to have embedHTML render some HTML on a docx template, but I don't see the lists or paragraphs being rendered.

  • I DO see PHPDocx's example code working fine on my machine (phpdocx/examples/Core/embedHTML/sample_1.php)
  • I DO see some HTML formatting being rendered via the template-oriented code. Tags like <em> and <b> work fine. Just not <p> or  <ul>/<li>.
  • If I copy the example HTML from sample_1.php & pasted it into my template-oriented code, I still don't see <p> or <ul>/<li> tags getting rendered. (In other words, I don't think it's an HTML formatting/encoding issue on my end.)

Is there an option I need to enable? Maybe there's another step I am missing?

Thanks for your help.

Posted by admin  · 19-12-2016 - 07:33

Hello,

If you are using templates you need to use the replaceVariableByHtml method:

http://www.phpdocx.com/api-documentation/templates/replace-variable-html-Word-document

to replace placeholders. If you are already using this method, please check that the 'type' option of this method is set as block (block elements need block type replacement, not inline) and Tidy is enabled and running.

Also check that any other option or style is not overwiting the element styles (such as existing Word styles or the option strictWordStyles in HTML methods).

Regards.

Regards.

Posted by coconnor  · 19-12-2016 - 21:29

Hi- thanks for the quick response.

Per your suggestion, I set 'type'=>'block' in the replaceVariableByHTML options, and all worked as expected.

For the record, I also saw evidence that you can do something similar via embedHTML: 

$template->embedHTML("<p>test</p>", array(
  'type' => 'block',
  'strictWordStyles' => TRUE,
));
}

Thanks for the help!