Forum


Replies: 1   Views: 1984
Block used within a paragraph will work but deletes the paragraph where the tag exists.
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 PKF_tech  · 17-10-2019 - 09:58

So I have a $tag********$ inserted into an existing paragraph in a Word template e.g.

 

This is the existing paragraph $tagblock html inserted% and the rest of the paragraph.

 

renders as

 

Content of the tag only.

 

If I use INLINE the inserted HTML only renders in the basic format but no line breaks etc.

Using the REPLACE variable to achieve the above.

Hope there is a solution to this?

 

Thanks

Tony

Posted by admin  · 17-10-2019 - 10:10

Hello,

The replace methods allow doing an inline replacement (keep the content of the paragraph but only inline elements are added) or a block replacement (remove the content of the paragraph keeping all new contents), but they don't allow mixing both.

Using DOCXPath (https://www.phpdocx.com/documentation/introduction/docxpath) and WordFragments you can replace an inline placeholder keeping all new contents (block and inline elements), but this task may require closing the previous block tag (w:p) and opening a new one (before and after the previous placeholder) to avoid generating corrupted documents.

As this may be a complex task, if you open a support ticket (https://www.phpdocx.com/support) and attach the template you are using, the dev team will generate a custom script.

Regards.