All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Testing Value of Low Variable via IF Statement

Todd Richards 3 Mar 2015 03:54 question, complete

I'm trying to test the value given by a Low Variable, but for some reason it's not working. For the record, I'm running EE 2.9.2 and LV 2.6.0, and my templates are using template layouts.

I need to get a value from another channel, so in my low variable (called lv_permissions) I have the following:

{exp:zoo_visitor:details}
{exp:playa:children field="member_firm_name"}{cf_firm_licensee}{/exp:playa:children}
{/exp:zoo_visitor:details}

This should produce a value of yes or no.

In my template, if I just spit out {lv_permissions}, I get the value expected. However, I'm trying to do something like this:

If "yes", provide all of this good stuff. If "no", then give a sad face and say I'm sorry.

I've tried several variations, including {if lv_permissions =="yes}Happy{if:else}Sad{/if}, but it's only producing my "Sad" message (even when the {lv_permissions} on it's own says "yes"). I've even tried to just remove everything inside lv_permissions and just have "YES". That doesn't even work.

And yes, the variable is set for "Enable early parsing".

I feel like I've done this before, but can't remember where. Or maybe I'm just dreaming.

Thanks for any suggestions that I might be missing!
Todd

Replies

  1. Low 3 Mar 2015 10:58

    This is due to parse order.

    Early parsed variables do not parse their content before hitting the template. Instead, their content is placed inside the template, which parses it.

    Consider this conditional:

    {if lv_permissions == 'yes'} That’s positive {/if}


    If your variable {lv_permissions} contains "YES", EE will evaluate this statement:

    {if 'YES' == 'yes'}


    Which is not true, as the equation is case sensitive.

    If your variable contains "yes", EE will evaluate this statement:

    {if 'yes' == 'yes'}


    Which is true.

    However, if your variable contains "{exp:some:tag}{some_var}{/exp:some:tag}", EE will evaluate this statement:

    {if '{exp:some:tag}{some_var}{/exp:some:tag}' == 'yes'}


    Which is false. The tags are not parsed, they are considered a literal string.

    If you just enter {lv_permissions} in the template, the tags will be placed there (stage #1, after which EE will parse the template (stage #5).

  2. Todd Richards 4 Mar 2015 04:04

    Thanks Low. I actually have the parse order sheet hanging by my desk, and stared at it last night trying to solve this. But your explanation above really helped. I will now print it out and hang it right next to it!

    I approached it slightly differently, and now have it working as I had hoped.

    Thanks again!