ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

EE IF Statements in PHP when using PHP Mail

November 29, 2011 9:09pm

Subscribe [2]
  • #1 / Nov 29, 2011 9:09pm

    Carlos Perez

    13 posts

    Hi - I’ve run into a curious behaviour when trying to send email using PHP Mail and ExpressionEngine. Perhaps I don’t quite understand the parse order correctly, or it’s a bug. I encounter it when trying to use if statements.

    When I try to run this code,

    $message =  '{exp:zoo_visitor:details limit="1" dynamic="no"}' . 
       '{if member_headline}<h2 class="h2">{member_headline}</h2>{/if}' .
       '{/exp:zoo_visitor:details}';

    The email I receive looks like this:

    {if "This is the headline"}
    This is the headline
    {/if}

    The strange thing is if I try to just visit the page and echo the $message variable, the if statements are parsed properly, and all I see is:

    This is the headline

    I have PHP enabled in the template and it is set to parse on output.

    Any ideas on what I can be doing wrong? Or if it’s a bug, or a limitation of using PHP Mail with ExpressionEngine?

    Carlos

    (EE 2.3.1)

  • #2 / Dec 01, 2011 3:45am

    John Henry Donovan

    12339 posts

    Hi Carlos,

    Most likely to do with parse order. Have you tried changed your template parsing stage to the opposite of what you are using currently?

    You could try this syntax too which would be recommended for checking for an empty state

    {if member_headline != ""}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases