Forum


Replies: 3   Views: 3351
How to duplicate blocks
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 richard.keller  · 13-04-2017 - 02:11

I'm currently trialing phpdocx, and I'm trying to duplicate a block multiple times. As far as I understand, I need to use WordFragment objects to do this. But how do I create a WordFragment based on an existing variable / block in a document?

In other words, I have a template with a block of content in it (eg. containing some text, some tables, and some variables). How can I create a WordFragment out of this block so that I can manipulate the variables inside it, and then paste the WordFragment back into the original template? 

Posted by admin  · 13-04-2017 - 09:41

Hello,

The cloning feature is not available in the trial package. It's included in Advanced and Premium licenses.

Regards.

Posted by richard.keller  · 13-04-2017 - 10:34

So I'm supposed to purchase a license without knowing 

1. How it works

2. If it works for our use case?

That doesn't really work for us. Are you not able to provide a trial license for 2 days so we can test the functionality? Surely you can't expect people to just purchase the Advanced license and hope it works without letting them test?

Do you at least have some documentation for how the clone functionality works? 

Posted by admin  · 13-04-2017 - 10:53

Hello,

UPDATE: cloneBlock method

The cloning method is provided through DOCXPath (https://www.phpdocx.com/documentation/introduction/docxpath). You can find the documentation about cloning contents on:

https://www.phpdocx.com/api-documentation/docx-path/clone-elements-in-docx

All methods included in all licenses of the library work as explained in the documentation pages and are fully tested.

When using an Advanced or Premium license, you have two approaches to accomplish what you need:

· Use DOCXPath to clone blocks or single contents, and replace the placeholders (variables): https://www.phpdocx.com/api-documentation/docx-path/clone-elements-in-docx

· Use a DOCX with the block you need to clone and merge it as many times as needed using the MultiMerge class: https://www.phpdocx.com/api-documentation/docxutilities/merge-Word-documents-with-PHP

Sorry but the only trial available is of the Basic package. Of course, we guarantee all features will work as expected and explained in the documentation and API pages.

Regards.