This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 4

Put 'Paragraph Text' in confirmation email in <p></p> tags. How?


  1. MvdL79
    Member

    The confirmation email is being send to our customers, however we also use the "Paragraph Text" area in our emails for extra information for clients. So when we enter text here, it will show up in the email we send to our customers. Ofcourse this works without issues, however the text entered in the "Paragraph Text" should be entered in <p> and </p> tags.

    It should only apply to the selected form ID in helper-functions.php.
    We already use several "cases" in this file for all our forms we use.

    Additional information: the 'Paragraph Text' we are targeting is in form_id 32 and concerns element_id 4. That's the one where the <p> tag should apply. In other words; it should put the text we enter in there in <p> text </p>.

    Hopefully I hear something back soon (this time).

    Thank you in advance.

    Regards

    //edit

    If <p></p> is not possible. Than <br><br> (at the end) would also be a workable solution for me.

    Posted 9 years ago #
  2. yuniar

    It is possible to do so through small modifications.

    Are you using the default {entry_data} for the email content template? Or using custom template along with the template variables?

    The code will differ a bit based on the above.


    MachForm Founder

    Posted 9 years ago #
  3. MvdL79
    Member

    Thanks for replying Yuniar. You might check the other thread, I also replied in there about the person copying Machform stuff.

    In regards to your question I always the custom variables, in other words never the {entry_data}. I create a template and use {element_x}. :)

    I am still using the code you gave me in the past so it automatically changes the selections for example:

    if($form_id == 32 && $data['element_type'] == 'radio'){
    				switch ($data['value']) {
    					case 'Option 1': $data['value'] = '<p>Explanation of option 1 in detailed form</p>';break;
    					case 'Option 2': $data['value'] = '<p>Explanation of option 1 in detailed form</p>';break;
    					case 'Option 3': $data['value'] = '<p>Explanation of option 1 in detailed form</p>';break;
    				}
    				$entry_details[$i]['value'] = $data['value'];
    			}

    Now I just want the contents in the textarea on form ID 32, which is element id 4, to be put in <p>textarea contents</p> so it looks good in the email the customer gets, instead of text being behind the previous line.

    Hope it makes sense.

    Posted 9 years ago #
  4. yuniar

    Ok, so the location of the code might not the same as your file, since you've done some other modifications, but it should be around line 3261 of "includes/helper-functions.php" file.

    Search for this code:

    if($data['element_type'] == 'textarea' && !$as_plain_text){
    	$template_values[$i] = nl2br($data['value']);
    }

    adjust it to be like this:

    if($data['element_type'] == 'textarea' && !$as_plain_text){
    	$template_values[$i] = nl2br($data['value']);
    
    	if($form_id == 32 && $data['element_id'] == 4){
    		$template_values[$i] = "<p>".$template_values[$i]."</p>";
    	}
    }

    That should do it.


    MachForm Founder

    Posted 9 years ago #
  5. yuniar

    Alternatively, assuming that you don't have any major changes with the file (I can't recall exactly), you can simply enclose the template variables with the P tag, like this:

    <p>{element_4}</p>

    This one won't require any file modification.


    MachForm Founder

    Posted 9 years ago #
  6. MvdL79
    Member

    Thanks for replying Yuniar.

    Tried the first solution, but it didn't work out. No clue why, but I only had one search result and changing that didn't work. Also the version of this Machform is kinda old, so probably thats the problem (I use a newer version for other forms, not this one). It only has 1582 lines (including many extra coded 'case'-lines).

    Yeah I though of your 2nd solution, however if nothing has been entered in it, it will result in a empty <p></p> tag in the email also, making the layout of the email looking less professional (creates empty space).

    Anyways, since I don't like to give up I compared a newer installed version of Machform with the older one (which I am using for these forms) and managed to track it back and make the changes there. After that I tested it and it indeed works now, I can tell by viewing the source, because it's now adding the text between <p> and </p> tags.

    Thanks Yuniar. :)

    Posted 9 years ago #
  7. yuniar

    That sounds great to hear :-)


    MachForm Founder

    Posted 9 years ago #

RSS feed for this topic

Reply