Forum


Replies: 2   Views: 3451
Templates apply to the wrong object
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 tremani  · 15-05-2014 - 17:53

I ran into a problem while generating multiple docx files at the same time. If I apply a template with the addTemplate() method, it will be applied to whatever object is rendered first through createDocx, even if that is a different object. This makes working with multiple CreateDocx objects somewhat risky. Is this a bug, or is there a method I could use to avoid this issue?



The following code demonstrates the issue:



// create two objects

$a = new CreateDocx();

$b = new CreateDocx();



// add a template to file a

$a->addTemplate('template.docx');



// render file b, it will contain the template that was added to file a

$b->createDocx('b');



// next render file a, which will not contain the template

$a->createDocx('a');



 


Posted by jorgelj  · 16-05-2014 - 08:57

Hello,



Please try unsetting the first object before creating the next one.



Regards.