Hello,
currently I am trying to use [(site_url)] in the template for the mail notifications that eform generates.
For example:
There is a new inquiry on your website <a href="[(site_url)]">[(site_url)]</a> bla...
But eform does not replace the system settings tag by the actual site URL...
-
☆ A M B ☆
- 24,524 Posts
The report tpl is only parsed by eForm and used as the email content, not the MODx parser (whereas the form tpl will get parsed by MODx after the eForm snippet generates the form into the document). So if you want anything other than the placeholders provided by eForm you need to use the eformOnBeforeMailSent event and a custom snippet/function to insert the values you want into eform’s $fields array. This will add the value to the placeholders that can be used in the report tpl. As an example, here’s the snippet with the function getServer() that I use to display the submitter’s IP address in the report.
<?php
function getServer( &$fields ){
// remote_addr
$fields['remote_addr']=$_SERVER['REMOTE_ADDR'];
$fields['remote_host']=$_SERVER['REMOTE_HOST'];
$fields['user_agent']=$_SERVER['HTTP_USER_AGENT'];
//return succes
return true;
}
?>
The report tpl
<h3>Contact Input</h3>
<strong>Name:</strong> [+name+]<br />
<strong>Email:</strong> [+email+]<br />
<strong>Website:</strong> [+url+]<br />
<strong>Message:</strong> [+message+]
<hr>
<strong>IP:</strong> [+remote_addr+]<br />
<strong>Host:</strong> [+remote_host+]<br />
<strong>User Agent:</strong> [+user_agent+]
And the snippet call:
[!getServer!]
[!checkField!]
[!eForm? &formid=`ContactForm` &tpl=`ContactForm` &report=`ContactReport` &to=`[email protected]` &subject=`domain.com Contact` &thankyou=`ThankYou` &from=`[+email+]` &fromname=`[+name+]` &replyto=`email` &eformOnBeforeMailSent=`getServer` &eformOnValidate=`checkField`!]
The checkField is another snippet/function that I use to check for a field that must be left empty as a spam prevention measure.