0

I'm really stuck and I know it's likely something small that I'm missing. I read the page in the wiki that relates to stash conditionals (https://gist.github.com/croxton/9d012297096892ca5c10), but I have to admit, I don’t completely follow whether it would apply the same way to set_list and get_list. Here’s my setup - I’m using the older way of inserting the wrapper template, using a traditional EE embed rather than a stash embed (perhaps that too should change?):

MY LOGIC TEMPLATE (simplified slightly to strip out details you likely don’t need to zero in on my problem)

{embed="_layouts/.catalog-product-details"}
{exp:stash:context name="stock-parts-product-details"}

    {exp:stash:set_list name="main_page_body" context="@" scope="site" parse_tags="yes" parse_conditionals="yes" save="yes" parse_depth="3"}

        {exp:channel:entries channel="products" dynamic="no" limit="1" url_title="{last_segment}" disable="relationships|categories|pagination|member_data" cache="yes" refresh="720"}

            {stash:current_product_category_url_title}{if segment_6}{segment_5}{if:else}{segment_4}{/if}{/stash:current_product_category_url_title}
            {stash:current_product_category_id}{if segment_6}{segment_5_category_id}{if:else}{segment_4_category_id}{/if}{/stash:current_product_category_id}

            {stash:product_name}{title}{/stash:product_name}

            various other individual variables that are stashed for the single product

        {/exp:channel:entries}

    {/exp:stash:set_list}

MY WRAPPER LAYOUT TEMPLATE

{exp:stash:get_list name="main_page_body" context="@" scope="site" save="yes"}

    <h1>{product_name}</h1>

    and other items stashed for the product from the logic template}

    {exp:channel:entries channel="products" dynamic="no" limit="1" category="{current_product_category_id}" url_title="{last_segment}" disable="relationships|categories|pagination|member_data" cache="yes" refresh="720"}

        {exp:ifelse parse="inward"}
            {if current_product_category_url_title == "widgets"}
                Width (A): {cf_prod_width}
            {if current_product_category_url_title == "whosits"}
                Height (A): {cf_prod_height}
                Width (C): {cf_prod_width}
            {if current_product_category_url_title == "somethingelse"}
                Length (A): {cf_prod_height}
                Inside Width (B): {cf_prod_inside_width}{if cf_prod_inside_width_special}{cf_prod_inside_width_special}{/if}

            THIS PATTERN CONTINUES FOR A LONG TIME DOWN THE PAGE BECAUSE THERE ARE 120 CATEGORIES WITHIN WHICH THE SET OF VARIABLES TO DISPLAY COULD BE DIFFERENT

            {if:else}
            {/if}
        {/exp:ifelse}

    {/exp:channel:entries}

{/exp:stash:get_list}

As a test, if I comment out (using EE comments so they don’t parse at all) the inside of the outer if:else conditions, the page loads in less than a second. But when the inside of each condition is kept alive in the template, the page is incredibly slow. So I can tell am I failing to setup the template in a way that would allow the stashed variable, current_product_category_url_title to be evaluated first and prevent the inside of non-matching conditions from being parsed. The product_category_url_title is being set in the logic template and retrieved in the layout template mainly because of my need to parse the segment data conditionally - it’s the “immediate parent” category that I’m after and it’s not always the same segment because I’m concatenating the URLs.

What is it that I’ve missed with the conditional setup? And could the conditionals actually be stored within the logic template (and would that make a difference?). Why are the inside conditionals parsing and how can i prevent that?

1
  • I don’t have a solution as such, but you should not need IfElse in 2.9+. IfElse was working around a problem with EE advanced conditionals that should not exist anymore. Is code inside your conditionals that are/should be evaluating false being run? Additionally, if there is a lot of further logic or EE tags, particularly tag pairs, that could be where you are running into a speed issue.
    – TJ Draper
    Nov 5, 2015 at 4:39

1 Answer 1

0

From what I can make out 'ifelse' is useful for early parsing conditionals, but still uses EE's conditional logic(?). This means that EVERY conditional (Pre 2.9) is evaluated even if the condition is met before they are all checked. (from tests I think I remember seeing they are even checked when commented out). (enable template debugging to see this).

There is an addon called switchee which handles this differently and might help with performance in your case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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