Forum


Replies: 4   Views: 1488
No linebreak after <p> tag using replacevariablebyhtml
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 admin  · 04-12-2020 - 11:14

Hello,

When an inline replacement type is done, block contents are cleaned from the new content (such as paragraphs), and only inline contents are added. To keep block contents from the content to be added when doing the replacements you need to set block as replacement type:

$docx->replaceVariableByHtml($var_name, 'block', $value, $html_options);

On the API documentation page of the method you can find the following information:

type

The substitution type, it can be:

"block": the variable, together with its containing paragraph, is replaced by the HTML content.
"inline": only the variable is replaced by the inline HTML content.

These options and how they work are the same than previous versions.

About the options you have posted they don't handle how to contents are replaced but other options: strictWordStyles (avoid some adding CSS styles, to be used with MS Word custom styles), isFile (to be used if the HTML is a file, not a string), parseDivsAsPs (change default div tags handling). On the previous API page these and other options are detailed.

Please note the linked topic in your post is about an extra space at the beginning of the paragraph, not about replacing placeholders

Regards.