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

Support archive

Unable to use Low variable in conditional statement

Nisar Shah 1 May 2015 15:30 problem, complete

Hi there,

I am not able to use Low variable in if condition, may because of parsing order but I am not able to figure out that issue

I have a channel entry whose field value is thema and its field name is {blog_type}, also I have low variable called thema_main_menu and its value is y,now I am trying something like this

{exp:channel:entries channel="channel_name" entry_id="228"}

{blog_type} //outputs thema
{thema_main_menu} //outputs y

{if thema_main_menu == "y"} //tried with single and without any quotes as well

SUCCESS

{/if}

{/exp:channel:entries}

I am not getting the SUCCESS, dont know why, please help

Regards
Nisar

Replies

  1. Nisar Shah 1 May 2015 15:31

    Tried switchee also, but no success

  2. Nisar Shah 1 May 2015 15:34

    Actually I was trying this

    {exp:channel:entries channel="channel_name" entry_id="228"}

    {blog_type} //outputs thema

    {thema_main_menu} //outputs y

    {if {blog_type}_main_menu == "y"} //so that it bcomes thema_main_menu

    SUCCESS

    {/if}

    {/exp:channel:entries}

    i.e mixing the field value with some text to make it a low variable, is it possible or not with low variable and conditional statements?

    While trying this I figured out that a simple if condition also does not work with LOW VARIABLE

    Please help or suggest

    Thanks in advance

  3. Low 1 May 2015 15:35

    Is early parsing enabled for that variable? If not, enable it.

  4. Low 1 May 2015 15:40

    Oh, using {if {blog_type}_main_menu == "y"} won't work because of parse order.

    You might be able to use this, tho (untested):

    {if '{exp:low_variables:single var="{blog_type}_main_menu"}' == 'y'}

  5. Nisar Shah 1 May 2015 15:43

    Thanks a ton mate, u saved my hours :)..but I tried the early parsing in settings of LOW, does it not apply to all variables automatically?

  6. Low 1 May 2015 15:45

    No, you have to enable EP on a per-var basis. See also this: http://expressionengine.stackexchange...

  7. Nisar Shah 1 May 2015 15:55

    Thanks for the update but this seems to work for me


    {exp:channel:entries channel="channel_name" entry_id="228"}
    {if {blog_type}_main_menu == 'y'}
    {embed="includes/main-menu"} //Text SUCCESS is in main-menu templ
    {/if}
    {/exp:channel:entries}


    This OUTPUTS SUCCESS when low variable {thema_main_menu} is checked(its a checkbox)

  8. Nisar Shah 1 May 2015 16:16

    Now another strange behavior, sometime it shows proper result and sometimes it does not,BTW I tried your exp

    {if '{exp:low_variables:single var="{template_selection}_main_menu"}' == 'y'} {embed="master-template/main-menu"} {/if}

  9. Nisar Shah 1 May 2015 16:33

    Just observed that keeping the field variable in template it works fine,I tried this

    <input type="hidden" value="{template_selection}" />

    {if '{exp:low_variables:single var="{template_selection}_main_menu"}' == 'y'} {embed="master-template/main-menu"} {/if}


    and it works fine