Forums

Use multiple fields in dynamic subject?

fiordhraoi 17 Mar, 2010
Hello,

I saw a couple of threads about combining a static value with a dynamic value for the subject line in the email. I'm a total PHP newbie, but I could probably manage to not break things horribly if I tried that. 🙂

http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=5&t=16575&p=44680&hilit=subject#p44680
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=5&t=14524&p=34399&hilit=subject#p34399

However, I need to combine 2 dynamic fields in the subject line. For example, if my form was:

Name (text_1)
Date of Last Visit (date_1)
Information Needed(text_2)

I want the subject to read something like

Information Request - text_1 , date_1

Any way for a PHP noob to manage that? 🙂

Thanks!
GreyHead 17 Mar, 2010
Hi fiordhraoi,

Try
<?php
$text_1 = JRequest::getString('text_1', '', 'post');
$date_1 = JRequest::getString('date_1', '', 'post');
$subject = "Information Request - $text_1, $date_1";
JRequest::setVar('subject', $subject);
?>
and use subject in the Dynamic Subject box

Bob
fiordhraoi 17 Mar, 2010
Hey Bob,

Thanks for the quick response! Not quite working out so far unfortunately. I'm getting this as the subject line:

Information Request - $text_1, $date_3

So it looks like it's just treating the variable names as text. I tried putting them outside the quotes, but that didn't work, just returned an error and I got a no subject email.

Also, just to double check - should this line

$date_1 = JRequest::getString('date', '', 'post');



read ('date', '', 'post') or ('date_1', '', 'post')?

Thanks for your help, I really appreciate it.
GreyHead 17 Mar, 2010
Hi fiordhraoi,

Sorry, my typos. That should be date_1 and this line needs double quotes
$subject = "Information Request - $text_1, $date_1";
I've corrected my original post.

Bob
fiordhraoi 17 Mar, 2010
Update: Got it working!


<?php
$text_1 = JRequest::getString('text_1', '', 'post');
$date_3 = JRequest::getString('date_3', '', 'post');
$subject = "Information Request - $text_1 , $date_3";
JRequest::setVar('subject', $subject);
?>


Using the double quotes in $subject for the concatenation did the trick. Thanks for the help!
This topic is locked and no more replies can be posted.