-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Description
Hi, guys!
I've a problem with creating templates.
At first, I've created .docx file which contains this structure:
${clone}
${name}
${phone}
${email}
${/clone}
Then, I should clone content between ${clone} and ${/clone}. I use $document->cloneBlock('clone', 3); for it but nothing happens. When I open this generated file I see the same structure.
${clone}
${name}
${phone}
${email}
${/clone}
Could you help me? What should I do to clone this block?
And one more question. Can I use variables in the cloned block more than one time, somethings like this:
$document->setValue('name#1', 'Name 1');
$document->setValue('name#2', 'Name 2');
Best regards, Eugene
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
franzholz commentedon Sep 24, 2014
The example "vendor/phpoffice/phpword/samples/Sample_07_TemplateCloneRow.php" answers your questions.
eugene-brit commentedon Sep 24, 2014
I've seen this examle. But in this example says about table rows and I've asked about "text blocks".
rando85 commentedon Nov 4, 2014
I think the problem is with Word, if you check the xml code you can notice the vars are not saved as well, Word insert many tags between the name of your var and the ${ }
You can try deleting and retyping the tags but the setValue won't help you.
chc88 commentedon Nov 12, 2014
See this issue: #341
My fix for the cloneBlock also includes the addition of _1 and _2 to variables within the cloned block
github-actions commentedon Nov 18, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.