Forums

[SOLVED] multiple email templates and validation

chrono_user 05 Oct, 2008
Hi, I am a newbie and am trying to do the following.

1) Form has a Select - Yes | No | Maybe
2) Depending upon the selection I want the email to be customized
3) I did see where we can set up multiple email blocks and each block has a template

But not sure how to proceed from there.....Many thanks in advance.
GreyHead 05 Oct, 2008
Hi chrono_user,

When you say you want it customised - it's still being sent to the same address? You just want to change the content?

If that's so then use a switch statement in the form email template:
<?php
$select = JRegister:getVar('select_field_name', '', 'post');
switch  ($select) {
    case 'Yes' :
?>
        // some html 
<?php
    break;
    case 'No :
?>
        // some html 
<?php
    break;
    case 'Maybe :
?>
        // some html 
<?php
    break;
}
?>

Bob
chrono_user 05 Oct, 2008
Thank you Bob, where would i put this segment of code in...

Chuck
GreyHead 05 Oct, 2008
Hi chrono_user,

It goes in the Email Template box. As I sketched it you need to put in three templates. In practice I guess some of the email text is common. If you post examples of the three emails here then we can give you a better guide.

Bob
chrono_user 05 Oct, 2008
Hi Bob,

The URL is <!-- w --><a class="postlink" href="http://www.ashakiran.com/asha/rsvp.html">www.ashakiran.com/asha/rsvp.html</a><!-- w -->

What I want to do is

1) If someone says they are coming (Option Yes) then I want the email to say

<p><br /> Thank you for RSVP'ing for the October 26th Event. We will Look forward to seeing you at UAH at the Business Administration Building (the building where chan auditorium is) in room 329 at 3.00PM.<br /> <br /> You can find directions on how to get there at this location<br /> <a href="http://cba.uah.edu/directions.html" target="_blank">http://cba.uah.edu/directions.html</a><br /> <br /> AshaKiran</p>

2) If someone says they are not coming (Option No) then I want the email to say

Sorry that you are not able to join us etc...

3) For the third option some other text...

Hope I am making sense
GreyHead 05 Oct, 2008
Hi chrono_user,
<?php
$select = JRegister:getVar('select_field_name', '', 'post');
?>
<p>Dear {name},</p>
<?php
switch  ($select) {
    case 'Yes' :
?>
<p><br /> Thank you for RSVP'ing for the October 26th Event. We will Look forward to seeing you at UAH at the Business Administration Building (the building where chan auditorium is) in room 329 at 3.00PM.<br /> <br /> You can find directions on how to get there at this location<br /> <a href='http://cba.uah.edu/directions.html' target='_blank'>http://cba.uah.edu/directions.html</a><br /> <br /> AshaKiran</p>
<?php
    break;
    case 'No :
?>
<p>Sorry that you are not able to join us etc... we hope to see you at a future event.</p>
<?php
    break;
    case 'Maybe :
?>
<p>Please make up your mind and let us know what you decide!!!</p>
<?php
    break;
}
?>
<p>Best wishes,<br />
The Event Managers</p>


Bob
chrono_user 05 Oct, 2008
Hi Bob,

I copied all the code you put in there and changed the select_field_name and put it in my email template (I have the WS..editor) so clicked on the html and posted it there...I turned even the DEBUG option on..but as you can see it does not see to work...Sorry to sound like a rock but what am I missing...

Many thanks in advance.
GreyHead 06 Oct, 2008
Hi chrono_user,

That's an unexpected result. Please will you take a form backup and post it here or email it to me at the address in my sig and I'll take a closer look.

Bob
Max_admin 06 Oct, 2008
Hi chrono_user,

the editor will strip any PHP code there, find the email you are using and at the email properties area, change "use editor" to no and apply then save the whole form and open it again so you can work with PHP mode!

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 06 Oct, 2008
Hi Max,

Ah, that explains the problem, thank you.

That option isn't in email properties for the version I have installed (BETA2) so I'll go and upgrade to v3.0 Stable. . .

Bob
chrono_user 06 Oct, 2008
Max,

I went to the SetupEmails and under that the Email Properties and I do not see any option about the editor all I have are

1) Email Format
2) Record IP
3) Enabled

Apply

Am i looking in the wrong place
Max_admin 06 Oct, 2008
Hi Bob, no problems, yes this one comes with V3.0 stable only!

@chrono_user, As Bob mentioned this feature will need V3.0 stable which is the last one after V3 BETA 2.

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
chrono_user 07 Oct, 2008
Hi Max & Bob

I upgraded to the latest stable and then put in the text from Bob in the email template and turned the debug on and this is what I am getting.

Parse error: syntax error, unexpected ':' in /home/ashakira/public_html/asha/components/com_chronocontact/chronocontact.php(392) : eval()'d code on line 8

The form is at <!-- w --><a class="postlink" href="http://www.ashakiran.com/asha/rsvp.html">www.ashakiran.com/asha/rsvp.html</a><!-- w --> and I am testing with the October-26th event. I do have the debug turned on if you wanted to test.
GreyHead 07 Oct, 2008
Hi chrono_user,

That's showing up an error on line 8 of the email template - it will probably break the back-end at that point.

What's the code in the email template box please? You may need to set 'Use template editor' to 'No' in the Email wizard properties to see this properly.

Bob
chrono_user 07 Oct, 2008
Bob, I set the template editor to NO and below is the code...

<div class="form_item">
<div class="form_element cf_heading">
<h3 class="cf_text">RSVP (October-26th)</h3>
</div>
</div>
<p>Dear {text_1},</p>
    <?php
    $select = JRegister:getVar('select_field_name', '', 'post');
    ?>
    <p>Dear {name},</p>
    <?php
    switch  ($select) {
        case 'Yes' :
    ?>
    <p><br /> Thank you for RSVP'ing for the October 26th Event. We will Look forward to seeing you at UAH at the Business Administration Building (the building where chan auditorium is) in room 329 at 3.00PM.<br /> <br /> You can find directions on how to get there at this location<br /> <a href='http://cba.uah.edu/directions.html' target='_blank'>http://cba.uah.edu/directions.html</a><br /> <br /> AshaKiran</p>
    <?php
        break;
        case 'No' :
    ?>
    <p>Sorry that you are not able to join us etc... we hope to see you at a future event.</p>
    <?php
        break;
        case 'Maybe' :
    ?>
    <p>Please make up your mind and let us know what you decide!!!</p>
    <?php
        break;
    }
    ?>
    <p>Best wishes,<br />
    The Event Managers</p>
chrono_user 07 Oct, 2008
Line 8 (should have been JRegister:: <-- should have had two and I only had one from what I understand) problem solved but line 22 I get the following error

Parse error: syntax error, unexpected T_STRING in /home/ashakira/public_html/asha/components/com_chronocontact/chronocontact.php(392) : eval()'d code on line 22

Bob & Max, I really appreciate your patience.
Max_admin 07 Oct, 2008
Hi, try to replace JRegister with JRequest ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
chrono_user 08 Oct, 2008
Max I am still getting the T_STRING error
Max_admin 08 Oct, 2008
something like
case 'No :
should be
case 'No' :
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 08 Oct, 2008
Hi chrono_user,

Apologies for my typo - well found Max!

There's another one too 'Maybe should be 'Maybe' I've corrected the code I posted earlier for both of these.

Bob
chrono_user 08 Oct, 2008
Thank you very very much Bob and Max for all your patience and help it worked!!!!!
This topic is locked and no more replies can be posted.