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

setComplexValue (link Element) by templateProcessor dosen't work properly. #1923

Closed
cit68 opened this issue Sep 2, 2020 · 1 comment
Closed

Comments

@cit68
Copy link

cit68 commented Sep 2, 2020

Hi everyone,
have an existing document,
inside it, I have a table with a placeholder for each row like ${url_N} with N from 0 to 9.
I'd like to insert dynamically a different link for each placeholder so i had write the following code:

$link = new PhpOffice\PhpWord\Element\Link('https://TEST.com', 'TEST', null, null, false);
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($path_archive_dir . $filename);
$templateProcessor->setComplexValue('url_0', $link);
$templateProcessor->saveAs($path_archive_dir . $filename);

In this way, the string "TEST" is correctly substituted in the placeholder, but no link appears.

If, when creates the Link Element set at true the "$internal" argument

$link = new PhpOffice\PhpWord\Element\Link('https://TEST.com/', 'TEST', null, null, true);

Now the string seems to become a link, even if the link that appears on hover is "#https://TEST.com".
why the "#" appears?
At last but not least, no link is opened when clicked, finally, the link doesn't work!

Someone can help me?

@cit68 cit68 closed this as completed Sep 2, 2020
@cit68
Copy link
Author

cit68 commented Sep 2, 2020

SOLVED by #1887

the following code works!

$link = new PhpOffice\PhpWord\Element\Link('https://url-example.com/', 'url', null, null, false);
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($path_archive_dir . $filename);
$templateProcessor->setLinkValue('url_0',$link);
$templateProcessor->saveAs($path_archive_dir . $filename);

@cit68 cit68 reopened this Sep 2, 2020
@cit68 cit68 closed this as completed Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant