Forum


Replies: 5   Views: 232
How to add url link in text type placeholder
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 admin  · 14-01-2025 - 07:13

Hello,

Please check and run the following sample included in the package: examples/Templates/replaceVariableByWordFragment/sample_2.php . This sample replaces a placeholder in a template with a new WordFragment that includes an image, a link, and a footnote.

The problem with your script is that it's using a new CreateDocx object instead of the DOCX template object to generate the WordFragment. Instead of:

$docx = new CreateDocx();
$wf = new WordFragment($docx);

it needs to use the DOCX template object, not a new object:

$wf = new WordFragment($templateDocx);

Also note that if you want to add a link to a URL you need to use http or https:

$url = 'https://www.hdfcfund.com';

otherwise, a local link is generated.

Regards.