Events Made Easy Forums How do I … Add line-break in #_FIELDS

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #60561
    Anonymous
    Inactive

    Hy Franky, when I use the #_FIELDS placeholder like

    $custom_fields = eme_replace_booking_placeholders( '#_FIELDS', $event, $booking, $is_multibooking = 0, $target = "html", $lang = '' ); echo $custom_fields;

    it would expect a line-break after each pair of “label: value”, but $custom_fields does not seem to contain the ‘\n’ you add in the program eme_rsvp.php on line 2366 – or maybe I got it all wrong?

    How can I use #_FIELDS so that I get
    custom 1: My input 1\n (or any other “thing” I can use to seperate the answers)
    custom 2: My input 2\n

    Background: I want to extract certain answers and show them as a table like

    <tr><td>custom 1</td><td>My input 1</td></tr>
    <tr><td>custom 1</td><td>My input 1</td></tr>

    so I need to seperate the answers for analysis of content and reformatting.

    Thank you!

    #60563
    Franky
    Keymaster

    Several things here:
    1) That is not the correct way to call that function, and you even have 1 parameter too many. You should use:
    $custom_fields = eme_replace_booking_placeholders( ‘#_FIELDS’, $event, $booking, 0, “text”); echo $custom_fields;
    2) Do a var_dump on it and check the result, or inspect the result in your browser (\n is not shown in your browser, it is in the resulting code)
    3) You made me realize I made an error for the end-of-line in case of html (then the end-of-line should be the br-tag), that is fixed with this small change:
    https://plugins.trac.wordpress.org/changeset/2204022/

    #60564
    Anonymous
    Inactive

    Oups – my function call parameters were really off!

    Here’s the corrected code and the result.

    $custom_fields = eme_replace_booking_placeholders( '#_FIELDS', $event, $booking, 0, 'text' );
    var_dump( $custom_fields );
    echo " count=" . substr_count( $custom_fields, "\n" );

    When I run the code on a Win-10 PC with XAMPP PHP Version 7.2.4, I cant find the \n in the $custom_fields nor in the browser inspect. The result of var_dump and echo is:
    string(78) "Anmeldung: NeinAnzahl Kinder 0-4: 0Anzahl Kinder 5-10: 0Anzahl Kinder 11-17: 0" count=0

    Now I ran the code on a hosted wordpress PHP Version 7.2.24, and there it works as expected.

    Any clues why XAMPP behaves like that?

    Anyway: I can use output html and work with the <br>.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘How do I …’ is closed to new topics and replies.
Scroll to Top