Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about Templates #382

Open
eugene-brit opened this issue Sep 24, 2014 · 5 comments
Open

Question about Templates #382

eugene-brit opened this issue Sep 24, 2014 · 5 comments

Comments

@eugene-brit
Copy link

eugene-brit commented Sep 24, 2014

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.

@franzholz
Copy link

The example "vendor/phpoffice/phpword/samples/Sample_07_TemplateCloneRow.php" answers your questions.

@eugene-brit
Copy link
Author

I've seen this examle. But in this example says about table rows and I've asked about "text blocks".

@rando85
Copy link

rando85 commented 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
Copy link
Contributor

chc88 commented 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
Copy link

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.

@github-actions github-actions bot added the Stale label Nov 18, 2022
@Progi1984 Progi1984 removed the Stale label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants