2

I have this code

{exp:low_replace find="\r|\n|\t" replace="" regex="yes"}
    {if '{member_group}' == 7}
        aaa
    {if:else}
        zzz
    {/if}
    {if '{logged_in_member_group}' != 7}
        bb
    {if:else}
        yyy
    {/if}
    {if {logged_in_member_group} == '7'}
        ccc
    {if:else}
        xxx
    {/if}
    {if {logged_in_member_group} != '7'}
        dddd
    {if:else}
        www
    {/if}
    {member_group}
{/exp:low_replace}

The output is

zzz yyy xxx www 7

This is weird because the output of {member_group} is 7.

Why are the conditionals not matching?

  • Did you ever figure this one out? If so, it is helpful if you mark an answer correct. – Stephen Callender Dec 9 '13 at 11:30
6

Member defined variables like {member_group} are parsed last by default, so your advanced (not simple) conditionals will never properly read the member data. View parse order pdf by Low.

You need to install an add-on to move the parsing of the member defined variables earlier. Try Low Variables, Mo' Variables, or any other add-on that has this feature.

| improve this answer | |
6

First off, you can't have any "else" statements in your conditional or it will be considered "advanced".

But more importantly in relation to how you're writing these: Simple Conditionals aren't just about the operators, control structures & variables, but the format is actually critical.

The actual format must be:

{if early_parsed_variable == "string"}
...
{/if}

Basically the left-hand side must NOT have curly brackets or quotes; and the right-hand side MUST have quotes. This is the exact and only pattern that EE looks for when trying to hunt down a Simple Conditional - along with the other requirements.

It's bewildering I know - it promted me to write a post about all the times you might think you've written a Simple Condition, but haven't:

http://johndwells.com/blog/when-a-simple-conditional-isnt

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.