Just checking, these are line breaks in the data fields - in a textarea for instance. I don't think that ChronoForms does any processing at present. I guess that Max might add something in a future version.
You could add some php processing yourself in the OnSubmit - before email field and see if that gives the reault you want?
Bob<br><br>Post edited by: GreyHead, at: 2007/09/11 18:30
setQuery("....
'".$_POST[nl2br('mailing_address_international')]."' ,
...
Thanks.
Edited to add code tags.<br><br>Post edited by: GreyHead, at: 2007/09/11 18:31
I too revieve emails with just a block of text and it would be lice to have some line breaks etc to make things tidy.
I'm looking at the section
On Submit code - before sending email:
but don't understand what php to put in there :blink:
Look forward to any advice,
Thanks
Andrew
hpinson edited the code generated at the autogenerated field!!
Sincerely,
Max
for example: i type the following text into the textarea.
Line One
Line Two
Line Three
Line Four
And I receive the email like this:
Line One Line Two Line Three Line Four
In the email source code, the text have line breaks:
...
<td>Line One
Line Two
Line Three
Line Four</td>
...
Who knows how to add a "<br />" tag after each line?
We can hack chronocontact.php, at line 209, and assuming your textarea name is textarea1, put this code :
$_POST['textarea1'] = str_replace("\n","<br>",$_POST['textarea1']);
Hi Andrew,
hpinson edited the code generated at the autogenerated field!!
Sincerely,
Max
Dear Admin,
It only renders textarea data with <br /> tag in the database, but not email.
Hi,
We can hack chronocontact.php, at line 209, and assuming your textarea name is textarea1, put this code :
$_POST['textarea1'] = str_replace("\n","<br>",$_POST['textarea1']);
Dear Max and All,
I put this code in the "Form Code" > "On Submit code - before sending email:", and it works
the "textarea1" is your textarea field name
<?php
$_POST['textarea1'] = str_replace("\n","<br>",$_POST['textarea1']);
?>
<br><br>Post edited by: isaac_ho, at: 2007/10/25 05:16
Max
Thanks very much for sorting that code out. Got mine working now after changing line 209 and then adding the code that isaac_ho supplied.
:cheer:
All the best
Andrew
I put this code in the "Form Code" > "On Submit code - before sending email:", and it works
the "textarea1" is your textarea field name
<?php
$_POST['textarea1'] = str_replace("\n","<br>",$_POST['textarea1']);
?>
<br><br>Post edited by: isaac_ho, at: 2007/10/25 05:16[/quote]
sorry! i make a mistake. in fact, place the above code into "Form Code" > "On Submit code - before sending email:" doesn't work.
Hi,
We can hack chronocontact.php, at line 209, and assuming your textarea name is textarea1, put this code :
$_POST['textarea1'] = str_replace("\n","<br>",$_POST['textarea1']);
Dear Admin,
Is there any way to do the same thing in "On Submit code - before sending email:" instead of hacking file "chronocontact.php"?
You mentioned in another thread that this already works with you ?!!!🙂
You can try this code in the on submit before email and see :
$html_message = str_replace("\n","<br>",$html_message);
Cheers
Max<br><br>Post edited by: GreyHead, at: 2008/01/04 12:19
Hi Issac,
You mentioned in another thread that this already works with you ?!!!🙂
You can try this code in the on submit before email and see :
$html_message = str_replace("\n","<br>",$html_message);
Cheers
Max
Dear Max,
i'm trying.<br><br>Post edited by: isaac_ho, at: 2007/10/30 04:29
Hi Issac,
You mentioned in another thread that this already works with you ?!!!🙂
You can try this code in the on submit before email and see :
$html_message = str_replace("\n","<br>",$html_message);
CheersMax
Dear Max,
Your code only works partially, because <br> is added into every line of the email HTML source code, looks like:
Subject: Form A - Show Directory Listing
Message-ID: <7dfed174fba4637b10297b3bdada7a45@penton.office.anywhere.localnet>
X-Priority: 3
X-Mailer: PHPMailer [version 1.73]
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="utf-8"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<br> <html>
<br> <head>
<br> <title></title>
<br> <base href="http://penton.office.anywhere.localnet/" />
<br> <style type="text/css">
<br>
<br> </style>
<br> </head>
<br> <body><table cellpadding='0' cellspacing='0' border='0' width='100%'><tr height='10'>
<br> <td width='40%' class='tablecell1'>exhibitor</td>
<br> <td width='60%' class='tablecell2'></td>
<br> </tr><tr height='10'>
<br> <td width='40%' class='tablecell1'>exhibitor_email</td>
<br> <td width='60%' class='tablecell2'></td>
<br> </tr><tr height='10'>
<br> <td width='40%' class='tablecell1'>misc_other</td>
<br> <td width='60%' class='tablecell2'></td>
<br> </tr></table></body></html>
<br><br>Post edited by: GreyHead, at: 2008/01/04 12:18
Cheers
Max
My email results still come without word wrap, but I haven't edited 209 yet, only added the code for before email sends.
Also, can anyone clarify or confirm that a break will happen, based upon the the text box character width? Such as, i type straight across without stopping; the text box pishes down to next line. WIll that cause a break?
My goal is to get the email results for that text area in paragraph form.
Thanks! -jz
Not tested but try this in the email template.
<?php
$textareas = array('textarea1', 'textarea2', 'textarea3');
foreach ($textareas as $textarea) {
$fields['$textarea'] = nl2br($fields['$textarea']);
if ( strlen($fields['$textarea']) > 75 ) {
$fields['$textarea'] = wordwrap($fields['$textarea'], 75, '<br />/n');
}
}
?>
Not tested so may be buggy! But in theory should replace all '/n's with '<br />' and then wordwrap the test at 75 characters. You may well need to tweak the settings to get exactly what you want.
And No, the textarea width does not carry into the stored text. Only breaks that you type will be saved - but the wordwrap should fix that for you.
Bob<br><br>Post edited by: GreyHead, at: 2008/01/04 17:52
Forgive me, but I'm not clear on the "email template". I have used the Form Code...where do I go from there?
Thanks, again. -jz
No problem.
The place to set up a custom email format is the Email template at the foot of teh Form Code tab. You'll also need to set 'In which format to send the results email:' to My Template on the General Tab.
The Email template takes a combination of php & html to format the email. You include field results by adding {fieldname} where you want them to appear.
Put the code snippet below at the beginning of the Email template and it will re-format the results for the textareas that you specify in the $textareas array line.
What you do with the rest of the email is up to you. You could simply reproduce the standard table layout, or use some html to give the fields neat headings.
Bob
I went in and just adjusted the fist text area to match my first text area:
<?php
$textareas = array('about_us', 'textarea2', 'textarea3');
foreach ($textareas as $textarea) {
$fields['$textarea'] = nl2br($fields['$textarea']);
if ( strlen($fields['$textarea']) > 75 ) {
$fields['$textarea'] = wordwrap($fields['$textarea'], 75, '<br />/n');
}
}
?>
My results are the same. Does that look ok and...do I need to do anything to that line 209? Is that related, or no.
Thx. -jz<br><br>Post edited by: GreyHead, at: 2008/01/04 18:27
Sorry, I've made a booboo . . . take the quotes out of $fields[$textarea] in five places please.
And no - if this works - it will replace the 209 hack.
Bob
Sorry, couldn't decipher.
<?php
$textareas = array('about_us', 'textarea2', 'textarea3');
foreach ($textareas as $textarea) {
$fields['$textarea'] = nl2br($fields['$textarea']);
if ( strlen($fields['$textarea']) > 75 ) {
$fields[$textarea] = wordwrap($fields[$textarea], 75, <br />/n');
}
}
?>
No all five of them were wrong:
<?php
$textareas = array('about_us', 'textarea2', 'textarea3');
foreach ($textareas as $textarea) {
$fields[$textarea] = nl2br($fields[$textarea]);
if ( strlen($fields[$textarea']) > 75 ) {
$fields[$textarea] = wordwrap($fields[$textarea], 75, <br />/n');
}
}
?>
Try this version
Bob
also, i think you recall, but just to clarify...i'm not manually entering any breaks. i think we're hoping the word wrap part works, right?
anyhow, sorry for the hassle. no joy as of yet.
thx. -jz
Hmmm . . . Please will you click the Backup Form icon and send me a copy of your form (email in my sig). I'll have a go later at trying the code on my setup, better to do it on your form than make one up though.
Bob
thx. -jz [file name=Intake.cfbak size=14116]http://www.chronoengine.com/components/com_fireboard/uploaded/files/Intake.cfbak[/file]
Here's the code to put in the Email template box
<?php
$textareas = array('about_us', 'locations', 'contact_us', 'services');
foreach ($textareas as $textarea) {
$fields[$textarea] = nl2br($fields[$textarea]);
if ( strlen($fields[$textarea]) > 75 ) {
$fields[$textarea] = wordwrap($fields[$textarea], 75, "<br />"«»);
}
}
?>
<table width="100%" cellspacing="0" cellpadding="0" border="0" >
<tbody>
<tr height="10" >
<td class="tablecell1" width="40%" >lockup1</td>
<td class="tablecell2" width="60%" >{lockup1}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >lockup2</td>
<td class="tablecell2" width="60%" >{lockup2}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >lockup3</td>
<td class="tablecell2" width="60%" >{lockup3}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >dpm</td>
<td class="tablecell2" width="60%" >{dpm}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >mt</td>
<td class="tablecell2" width="60%" >{mt}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >reflex</td>
<td class="tablecell2" width="60%" >{reflex}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >pedicure</td>
<td class="tablecell2" width="60%" >{pedicure}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >email</td>
<td class="tablecell2" width="60%" >{email}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >worldtag</td>
<td class="tablecell2" width="60%" >{worldtag}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >steptag</td>
<td class="tablecell2" width="60%" >{steptag}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >needsdomain</td>
<td class="tablecell2" width="60%" >{needsdomain}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >no_need_domain</td>
<td class="tablecell2" width="60%" >{no_need_domain}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >domain1</td>
<td class="tablecell2" width="60%" >{domain1}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >domain2</td>
<td class="tablecell2" width="60%" >{domain2}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >domain3</td>
<td class="tablecell2" width="60%" >{domain3}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >subdomain</td>
<td class="tablecell2" width="60%" />{subdomain}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >no_subdomain</td>
<td class="tablecell2" width="60%" />{no_subdomain}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >needs_hosting</td>
<td class="tablecell2" width="60%" />{needs_hosting}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >no_hosting_needed</td>
<td class="tablecell2" width="60%" />{no_hosting_needed}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >about_us</td>
<td class="tablecell2" width="60%" >{about_us}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >locations</td>
<td class="tablecell2" width="60%" >{locations}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >contact_us</td>
<td class="tablecell2" width="60%" >{contact_us}</td>
</tr>
<tr height="10" >
<td class="tablecell1" width="40%" >services</td>
<td class="tablecell2" width="60%" >{services}</td>
</tr>
</tbody>
</table>
It's just a table to display the results (I think I may have missed on field somewhere so you'll need to check.
Also, you need to remove the <form> tags from your form code - as ChronoForms will add its own. (I'm not sure that the webbot validation will work here.)
And, lastly, set the 'In which format to send the results email:' box to My template.
Note: If you want to use debug to see the results you'll need to temporarily remove the Redirect URL form the Form URLs page.
Bob
I was following this thread to resolve what I believe to be the same problem. I'm not emailing my code anywhere - just storing in the db. So, my way of accessing the data is through your admin interface. However, the data entered into the textarea is displayed without any returns or breaks... hence why I found this thread.
I added your suggested php code to my HTML form code (editing for my own fields, of course) and receive the following error when loading the form in a browser to test:
Notice: Undefined variable: fields
Any thoughts?
Thanks,
Nick.
That's a PHP warning message, you can usually remove them by setting Error Notices to System Default in Site Configuration.
Can you tell me what the rest of the message says - it should have a file name and a line number or two.
Thanks
Bob
Thanks for the reply. Here's the full error:
Notice: Undefined variable: fields in ...root/components/com_chronocontact/chronocontact.html.php(83) : eval()'d code on line 4
Thanks again,
Nick.
The warning appears to be triggered by Line 4 of your HTML form code, please can you post the first dozen lines here.
Thanks
Bob<br><br>Post edited by: GreyHead, at: 2008/04/22 00:24
Here's the part of the code that it's referring too... just an edited version of what I got from this forum🙂
<?php
$textareas = array('qquestion');
foreach ($textareas as $textarea) {
$fields[$textarea] = nl2br($fields[$textarea]);
if ( strlen($fields[$textarea]) > 75 ) {
$fields[$textarea] = wordwrap($fields[$textarea], 75, "<br />");
}
}
?>
Thanks in advance for the help!
Nick.
Make that
<?php
$fields = array(); // add this line
$textareas = array('qquestion');
foreach ($textareas as $textarea) {
$fields[$textarea] = nl2br($fields[$textarea]);
if ( strlen($fields[$textarea]) > 75 ) {
$fields[$textarea] = wordwrap($fields[$textarea], 75, "<br />");
}
}
?>
and it should go away. The message is a PHP warning that a variable is being used without being declared first. In this case it's harmless but looks messy. On a production site it's better to turn these warnings off.
Bob
It seems now I'm getting a different error though...
Notice: Undefined index: qquestion in root/components/com_chronocontact/chronocontact.html.php(83) : eval()'d code on line 5
We're working on a Dev site ...just getting things ready🙂
Thanks again, Nick.
That's weird, looks like a punctuation error somewhere. Can you take a Form Backup and mail it to me at the address in my sig.
Thanks
Bob
I am trying to deal with the multiline issue as well and don't seem to have any luck yet.
After reading the previous relevant posts and searching for nl2br, I concluded that I should enter the following code in the "On Submit code - before sending email" field at the "Form Code" tab of my form, but it doesn't seem to work:
<?php
$fields = array();
$textareas = array('pres_desc', 'prep_desc', 'app_desc', 'exer_desc');
foreach ($textareas as $textarea) {
$fields[$textarea] = nl2br($fields[$textarea]);
if ( strlen($fields[$textarea]) > 75 ) {
$fields[$textarea] = wordwrap($fields[$textarea], 75, "<br />");
}
}
?>
I receive no error messages, it simply doesn't work, after filling in a new form the lines still appear together.
I am not using e-mails, I am just saving the submitted data in a database table and use Chronoconnectivity to display them.
Am I missing something here?
Thanks in advance,
Emily.
This is code from a year ago for an older version of ChronoForms. The Logic is still correct but I don't see that this is picking up the submitted information or putting the revised areas anywhere useful. Please try this variant.
<?php
$textareas = array('about_us', 'textarea2', 'textarea3');
foreach ($textareas as $textarea) {
$text_data = JRequest::getVar($textarea, '', 'post');
$text_data = nl2br($text_data);
if ( strlen($text_data) > 75 ) {
$text_data = wordwrap($text_data, 75, <br />/n');
}
JRequest::setVar($textarea, $text_data, 'post');
}
?>
Bob
thanks a lot for the prompt reply, I really appreciate it!
Unfortunately I had no luck with the new version either...
(I did change the names in the textarea array to match the fields in my form)
I put the following text in the form:
aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa
bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb
ccc ccc ccc ccc ccc ccc ccc ccc
and I receive:
aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb ccc ccc ccc ccc ccc ccc ccc ccc
In fact, I don't really mind about the wordwrap, as long as the user defined line changes are maintained.
Any thoughts?
This is fixed in RC5.1, you may contact me through the contact us page to get a pre release version!
Cheers
Max