Forums

Adding plain text in "Dynamic Suject"

SPABO 26 May, 2010
Hope you can help,

I would like to have plain text (extra) in the dynamic subject

eg
Say field is called FIELDNAME, theh subject would be

Your request dated FIELDNAME

Hope you can help !!
GreyHead 26 May, 2010
Hi SPABO,

You can build the value in the OnSubmit Before box
<?php
$fieldname = JRequest::getString('fieldname', date('Y-m-d'), 'post');
JRequest::setVar('subject', 'Your request dated '.$fieldname);
?>

Then put subject in the Dynamic Subject box

Bob

Later: added a missing '
SPABO 26 May, 2010
Bob,

I put in this in the OnSubmitbefore
<?php
$Wedstrijddatum = JRequest::getString('Wedstrijddatum', date('Y-m-d'), 'post);
JRequest::setVar('subject', 'Uw aanmelding van '.$Wedstrijddatum);
?>


and I get this error

Parse error: syntax error, unexpected T_STRING in /var/www/vhosts/golfparkspandersbosch-club.nl/httpdocs/components/com_chronocontact/libraries/customcode.php(64) : eval()'d code on line 3
GreyHead 26 May, 2010
Hi SPABO,

I missed a ' after post'
$Wedstrijddatum = JRequest::getString('Wedstrijddatum', date('Y-m-d'), 'post');


Bob
SPABO 26 May, 2010
Excellent Bob!
In this way I could amend al the "emailboxes", simply by changing the text en subject, subject_1, etc

Just for my curiosity, why did you put , date('Y-m-d'), in the code ??
By pm is fine with me, eager to learn!!
GreyHead 26 May, 2010
Hi SPABO,

The date was to add a default value (today's date) in case the input from the form was empty. Just keeps the subject making sense.

Bob
SPABO 28 May, 2010
Okay Bob'

Thanks again !!

How can I set this topic as CLOSED or SOLVED ?
This topic is locked and no more replies can be posted.