TCPDF : Adding link to email/Thank you message

santosh.karkhanis 10 Dec, 2015
Not clear on how to add a TCPDF form link to email or Thank you message.
Successfully given the form as attachment with e-mail.
Refering to
https://www.chronoengine.com/faqs/61cfv4/cfv4tutorials/4133howcanicreateapdfincludingformresults.html
But not getting it.
If I add the code
<?php
$form‐>data['pdf_link'] = "<a href='{$form>
files['cf_pdf_file']['link']}' >Click here</a>";
?>
to my e-mail message, I do not get anything in e-mail.
GreyHead 10 Dec, 2015
Hi santosh,

Please check your PHP and add the missing - in $form->files
<?php
$form‐>data['pdf_link'] = "<a href='{$form->files['cf_pdf_file']['link']}' >Click here</a>";
?>

Bob
santosh.karkhanis 10 Dec, 2015
I am confused on where to add the code.
I added in 'Email template' box as shown.
But not getting any text in the email (except IP address).
GreyHead 10 Dec, 2015
Hi santosh,

. . . use a Custom Code action after the TCPDF action and before the Email action with code like this:
<?php
$form->data['pdf_link'] = "<a href='{$form->files['cf_pdf_file']['link']}' >Click here</a>";
?>
Then you would add {pdf_link} to your Email template or Thank You page action.

Bob
santosh.karkhanis 10 Dec, 2015
Tried. But still the email is blank (only IP address)
GreyHead 10 Dec, 2015
HI santosh,

There is nothing to see in the action. Please drag the Debugger down so that you can see what is being created by the Custom code.

Bob
GreyHead 10 Dec, 2015
Hi santosh,

You haven't corrected the typo in $form->files as far as I can see.

Bob
GreyHead 12 Dec, 2015
Hi Santosh,

There's still a - missing in $form->files

Bob
santosh.karkhanis 12 Dec, 2015
Sorry. That was wrong screenshot.
It is done, without results.
Latest screenshot is here.
santosh.karkhanis 12 Dec, 2015
The code now
<?php
$form‐>data['pdf_link'] = "<a href='{$form->
files['cf_pdf_file']['link']' >Click here</a>";
?>


But still no results
GreyHead 12 Dec, 2015
Hi santosh,

If you copied and pasted the code there is an extra line-break and a missing }

What do you see in the debugger output?

Bob
santosh.karkhanis 13 Dec, 2015
Thanks.
It worked. Now I got the link in the email.
But the link is relative & not absolute. Hence not working.
In debugger output, I got
[pdf_link] => <a href='/home2/samarths/public_html/components/com_chronoforms5/chronoforms/pdfs/feedback-form1/pdf-test_20151213003243.pdf' >Click here</a>

A screenshot of debugger output is attached.

Regards
GreyHead 13 Dec, 2015
Hi santosh,

Please download the TCPDF action from the site and reinstall it using the Install action icon in the Forms Manager toolbar. There was a bug in some versions that put the 'path' in the 'link' entry, I think that Max has fixed that in the current version.

Sorry I didn't notice that before.

Bob
santosh.karkhanis 14 Dec, 2015
Not working after reinstall.
My previous file was unloaded from the site on 10th Dec. Hence I expect that the bug is still there in the file.

Any way, that is not my prime requirement. I will wait till the bug is removed.
Thank you for your prompt help.

Regards
lydianp18 13 Jan, 2016
I just installed the most recent version of the action, and the bug still exists in the link output - it's still doing the path. How can I fix this?
GreyHead 14 Jan, 2016
Hi lydianp18,

You can use a Custom Code action after the TCPDF action like this
<?php
$temp = $form->files['cf_pdf_file']['link'];
$temp = str_replace(JPATH_SITE, JUri::root(), $temp);
$temp = str_replace('//', '/', $temp);
$form->files['cf_pdf_file']['link'] = $temp;
?>

Or you can edit the /administrator/components/com_chronoforms5/chronoforms/actions/tcpdf/tcpdf.php about line 178 to be like this
			if(strlen(trim($config->get('pdf_post_name', ''))) > 0){
				$form->files[trim($config->get('pdf_post_name', ''))] = array('name' => $PDF_file_name.".pdf", 'path' => $PDF_file_path, 'size' => 0);
				$form->files[trim($config->get('pdf_post_name', ''))]['link'] = str_replace(array(\GCore\C::get('GCORE_FRONT_PATH'), DS), array($site_link, "/"), $upload_path.$PDF_file_name.".pdf");
				$form->data[trim($config->get('pdf_post_name', ''))] = $PDF_file_name.".pdf";
				$form->debug[$action_id][self::$title][] = $PDF_file_path.' has been saved correctly.';
			}
The third line here should be different from the one you have.

Bob
kate_ee 16 Nov, 2016
Hi There,

Could I add TCPDF form link to BOTH email & Thank you message at the same time?


Kate_ee
GreyHead 16 Nov, 2016
Hi Kate_ee,

Yes.

Bob
This topic is locked and no more replies can be posted.