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

Support archive

Can I use a Low Variable radio group to conditionally show the beginning channel entries tag.

L2 5 Jul 2012 18:31 question, complete

I have two Low Variables. The first called "lv_headline_featured_sort" and is a radio group that allows the client to select whether to order entries by "Date" or "Manual". The second LV is only relevant if the client chooses "Manual" in the first LV. This second LV "lv_headline_featured" is a drag and drop select field that the client selects 7 articles to manually show and order.

The only difference in my {exp:channel:entries} tag parameters is if:
- "lv_headline_featured_sort" is "Date" then use orderby="date"
- "lv_headline_featured_sort" is "Manual" then use fixed_order="{lv_headline_featured_manual}"

I'm assuming it's a parse order issue.

The other thought I had was if I could just use a global variable to change the "orderby" and "fixed_order" parameters.

Attached is a screenshot of my code. I highlighted the code with a green box.



Thanks.
Lori

Replies

  1. Low 6 Jul 2012 08:14

    Hi Lori,

    You're right, it's a parse order issue. The advanced conditional is parsed after the tags.

    Here's what I'd do. Make sure all three LVs you mentioned have early parsing enabled. Then use a combination of simple conditionals and preload_replace variables to set variables for parameter values. Something like this:

    {if lv_headine_featured_sort == "Date"} 
    {preload_replace:pre_orderby="date"}
    {preload_replace:pre_fixed_order=""}
    {/if}
    {if lv_headine_featured_sort == "Manual"}
    {preload_replace:pre_orderby=""}
    {preload_replace:pre_fixed_order="{lv_headline_featured_manual}"}
    {/if}
    {exp:channel:entries channel="articles" orderby="{pre_orderby}" fixed_order="{pre_fixed_order}" ...}
    <!-- etc. -->

  2. L2 6 Jul 2012 09:45

    Thanks Low. I'll give that a shot and let you know how I make out.

  3. L2 10 Jul 2012 17:25

    Hi Low,

    I tried your suggestion and it seems to only want to read the first conditional and skips the second one. Here's my code:

     
    <!--START Featured-->
    {if lv_headine_featured_sort == "Manual"}
    {preload_replace:pre_orderby=""}
    {preload_replace:pre_fixed_order="{lv_headline_featured_manual}"}
    {/if}

    {if lv_headine_featured_sort == "Date"}
    {preload_replace:pre_orderby="date"}
    {preload_replace:pre_fixed_order=""}
    {/if}

    {exp:channel:entries channel="articles" orderby="{pre_orderby}" fixed_order="{pre_fixed_order}" limit="1" dynamic="no" status="open" disable="categories|category_fields|member_data|pagination"}
    <div class="featured">
    <span class="ribbon">Featured</span>
    <div class="featuredListing">
    <h1><a href="{url_title_path=articles/detail}">{title}</a></h1>
    <div class="entryTop">
    <p><span class="bold">{entry_date format="%F %d, %Y"}</span> | <span class="italic">by {author}</span></p>
    </div>
    {exp:eehive_hacksaw words="60" allow="<sup><p>" append="..."}
    {article_body}
    {/exp:eehive_hacksaw}

    <p><a href="{url_title_path=articles/detail}">Continue Reading &raquo;</a></p>
    </div><!-- END Featured Content -->

    </div><!--END Featured-->
    {/exp:channel:entries}

  4. Low 10 Jul 2012 19:04

    Is early parsing enabled for the lv_headine_featured_sort variable?

  5. L2 10 Jul 2012 19:12

    Yes. Early parsing is enabled on "lv_headine_featured_sort" and "lv_headine_featured_manual" variables.

    Thanks.
    Lori

  6. Low 10 Jul 2012 22:18

    Are the values of the variable really "Date" and "Manual", case sensitive? What are they outputting if used just like {lv_headine_featured_sort} ?

  7. L2 10 Jul 2012 22:36

    Yes, they are case sensitive. I am using a capital letter "Date" and "Manual".

    This is strange. I saw the output "Date" and "Manual" once. Now I can't get it to output. It keeps outputting the variable name {lv_headine_featured_sort}. I thought it had to do with where I placed the variable (inside or outside of the channel entries tag) but now I can't get it to work anywhere.

    Thanks.
    Lori

  8. Low 10 Jul 2012 22:38

    Is this online somewhere so I can take a look? If so, you can send SuperAdmin login credentials to hi at gotolow dot com.

  9. L2 10 Jul 2012 22:51

    Just sent you an email.

  10. Low 11 Jul 2012 08:55

    Ha, my bad. Typo in the example code. "headine" instead of "headline". Try this:

    {if lv_headline_featured_sort == "Date"} 
    {preload_replace:pre_orderby="date"}
    {preload_replace:pre_fixed_order=""}
    {/if}
    {if lv_headline_featured_sort == "Manual"}
    {preload_replace:pre_orderby=""}
    {preload_replace:pre_fixed_order="{lv_headline_featured_manual}"}
    {/if}

  11. L2 11 Jul 2012 12:58

    I missed that typo too. Thanks so much for catching it. Everything is working properly.

    I have a general question about the preloads...

    I noticed that you have some preloads empty like {preload_replace:pre_orderby=""}. If my channel entries tag doesn't contain that parameter, do I need to put it in the IF statement?

    Thanks so much for all of your help!

    Lori

  12. Low 11 Jul 2012 13:02

    Having that variable as an empty string doesn't matter when using it as a parameter value. In the above code, having an empty {pre_orderby} param will simply tell the channel:entries tag to fall back to the default. But in your case, the fixed_order param is set, so that order will be used.

    Same goes for the fixed_order parameter. Having fixed_order="" in your channel:entries tag is the same as not having the parameter at all.

  13. L2 11 Jul 2012 13:21

    Thanks so much for the explanation and fantastic support!

    Lori

  14. L2 18 Sep 2012 20:25

    Hi Low,

    I'm trying to use the preload again but without success. I'm wondering if it's a parse issue. This time I'm trying to preload a variable in a Solspace User entries pair.

    I have two Low Variables. Both have early parsing enabled.
    (1) lv_test_members_display is a radio button and "Show/Hide" are my options.
    (2) lv_test_members_id is a text area that I have entered in member_ids (example: 7|24|55)

     
    {if lv_test_members_display == "Show"}
    {preload_replace:pre_member_id=""}
    {/if}
    {if lv_test_members_display == "Hide"}
    {preload_replace:pre_member_id="not {lv_test_members_id}"}
    {/if}

    {exp:user:users group_id="9|12" member_id="{pre_member_id}" orderby="screen_name" sort="asc"}
    {embed="embeds/dashboard_stats_scans_trainee" my_trainee_member_id="{member_id}"}
    {/exp:user:users}


    I've tried the code with surround the LV with "{}", changing parse order for each LV, and other things. I'm probably coding it incorrectly, or perhaps it's a conflict with Solspace User.

    Any advice you can give would be much appreciated.

    Thanks.
    Lori

  15. Low 18 Sep 2012 20:30

    Hi Lori,

    What are your EE and LV versions in this case?

    Also, you can turn on template debugging, where you can see how the User tag parameters are set. What does that tell you?

  16. L2 18 Sep 2012 20:39

    Hi Low,

    EE 1.7.3
    LV 1.3.7

    Both with and without Template Debugging enabled the full page displays but in the location where my {if} code is I see the following:

    {preload_replace:pre_member_id=""}

    This text replaces the actual contents of the section that should be displayed. It's like it's parsing the preload statement as text instead of putting in the contents of the entries pair.

    Template Debugging didn't show anything on the page.

    Thanks.
    Lori

  17. Low 18 Sep 2012 20:41

    Yeah, that'll be because the preload_replace vars were called assign_variable vars back in EE1. Might want to change the syntax. :)

  18. L2 18 Sep 2012 20:54

    You are the bomb, Low! It never dawned on my that the syntax might be different between versions. This is my only client still on EE 1.x and I forgot that some of the terms have changed.

    Thank you so much!
    Lori