Forums

Emails template

bruno_34 05 Feb, 2010
Firstly, sorry for my poor English ...
Is it possible to configure different email template sent to the user, depending on the selection made on a radio button ? And if it's possible, how can i do ?
Thank you for your answers
Best regards
GreyHead 05 Feb, 2010
Hi bruno_34,

Yes you can do this.

There are two different ways:

1) You can set up two different email setups and switch between them. There was a recent thread on how to do this.

2) You can use one Email Setup and use PHP in the Email Template box to show different code depending on the form results.

Bob
bruno_34 05 Feb, 2010
Thank you for yor quick response.
I'm not experienced enough with php to use the second solution you propose.
And for the first one, my problem is precisely how to "switch" between the two email setups.
I'm desperately searching the thread on this feature.

thanks for your time
GreyHead 07 Feb, 2010
Hi Bruno_34,

Here is some code that will switch emails 'ON' if the user clicks checkboxes in the form. There are three email setups - all disabled in the Properties box.

The form has three checkboxes in an array with values 1, 2 & 3

Depending which boxes are clicked, those emails will be enabled and sent.
<?php
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$check0 = JRequest::getString('check0', '', 'post');
if ( $check0 ) {
  $check0 = explode(', ', $check0);
  foreach ($check0 as $v ) {
    $MyFormEmails->setEmailData($v, 'enabled', true);
  }
}
?>

You could extend this to disable emails by using
$MyFormEmails->setEmailData('email_id, 'enabled', false);

Bob
bruno_34 08 Feb, 2010
Thanks again,
i'm going to try this right now
orengi 20 Aug, 2010
Hi!

I'm searching the way to put PHP in the email template

GreyHead says:
"2) You can use one Email Setup and use PHP in the Email Template box to show different code depending on the form results."

I'm trying to send a $variable to the email:

In the content of joomla, I put a link to chronoform form with a $variable called "$producto". The url is some like this:

http://www.myweb.com/index.php/contact/form?producto=producto01
(where producto01 is the name of the product that we see in the content article)

In the form code (backend chronoforms) I put this code
This is the product name: <?php $producto2=$_GET["producto"]; echo $producto2;  ?>

(this give me in the content before de form "This is the product name: producto01")

Well, can I put with php the $variable "$producto2" in the email template?

Thanks a lot!!
GreyHead 28 Aug, 2010
Hi orengi,

There are three different ways to do this:

a) You can turn off the HTML editor for the Email template in the Email Setup | Properties box. Then you can add PHP directly to the Email Template.

b) You can keep the HTML Editor but create a new value in the OnSubmit Before Code box:
<?php
$prodcuto = JRequest::getVar('producto', '', 'get');
JRequest::setVar('producto', $producto);
?>
and then use {producto} in the Email Template.

c) [added after orengi's post] You can also set the value in the Form HTML and put it into a hidden input.
<?php
if ( !$mainframe->isSite() ) { return; }
$prodcuto = JRequest::getVar('producto', '', 'get');
?>
<input type='hidden' name='producto' value='<?php echo $producto; ?>' />
then you can use {producto} in the email template.

Bob

Later: added the third way suggested by orengi for completeness
orengi 28 Aug, 2010
Thanks a lot!!

finally I created a "hidden" input with the value=$producto (in the form's code). Then I can use it in the email template with the code {hidden}. It works fine!

And I can use in the "after submit" too

Is what I wanted, I thought that I need to put in PHP, but this way is perfect.

(anyway, thanks for you reply, can be useful later)

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