1

The following code is causing a 8-9 second page load delay on our site and I’m trying to whittle this down however I’m not sure which conditionals to try to change in order to best affect the load times

I’ve tried using the ifelse addon from Devot:ee however it doesn’t seem to be helping at all (where I’ve placed it!)

There are about 80 categories and the code below picks out 4 of them. The channel that the products are pulled from has about 1000 entries

Using EE 2.9.0

    {exp:channel:categories channel="products" style="linear"}
    {exp:ifelse parse="inward"} 
    {if hp-featured == "Yes"}

        <h2 class="hpH2"><a href="{path=products/l/c/{category_url_title}}">Best Selling {category_name}</a></h2>
        {exp:low_reorder:entries set="product_order" category="{category_id}" dynamic="no" disable="member_data|pagination|primary_category|categories|category_fields|misc_content|news|homepage_adverts|about" limit="3" url_title="{embed:the_url_title}" }
        <style type="text/css">
        #MI{product_code} {position:absolute; z-index:2; visibility:hidden; width:215px; margin-top:195px; background:url(/images/bg-list-moreinfo.png); padding:3px 5px; text-align:center; font-weight:normal; font-size:11px;}
        </style>
  <div class="productSingle" onmouseover="P7_autoLayers(0,'MI{product_code}')" onmouseout="P7_autoLayers(0)">
  <div id="MI{product_code}"><a href="{url_title_path='products/detail'}" title="{title} Prices and Ordering">more info &raquo;</a></div>
  <a href="{url_title_path='products/detail'}"><img src="{product_image:thumbnail}" alt="{if product_thumbnail_alt_tag !=""}{product_thumbnail_alt_tag}{if:else}{title}{/if}" title="{title}" width="225" height="225" border="0" /></a> <a href="{url_title_path='products/detail'}">{title}</a><br />
  {if '{bulk_discounts:total_rows}' == 5}
        {bulk_discounts}
            {if field_row_count == 5}from {if saleprice}&pound;{saleprice}<s> &pound;{price}</s>{if:else}&pound;{price}{/if} per item{/if}
        {/bulk_discounts}
  {/if}
  {if '{bulk_discounts:total_rows}' == 4}
        {bulk_discounts}
            {if field_row_count == 4}from {if saleprice}&pound;{saleprice}<s> &pound;{price}</s>{if:else}&pound;{price}{/if} per item{/if}
        {/bulk_discounts}
  {/if}
  {if '{bulk_discounts:total_rows}' == 3}
        {bulk_discounts}
            {if field_row_count == 3}from {if saleprice}&pound;{saleprice}<s> &pound;{price}</s>{if:else}&pound;{price}{/if} per item{/if}
        {/bulk_discounts}
  {/if}
</div>
  {/exp:low_reorder:entries}

    {/if}
    {/exp:ifelse}
{/exp:channel:categories}
1

The code is slow because you are nesting tags. To speed up, you'll need to un-nest which will reduce the amount of queries. The linked blog post uses PHP in the template to achieve this. Nowadays, people tend to use Stash to do the same.

If you can't un-nest, you'll probably have to cache the hell out of that page.

2
  • Thanks Low How do I specify the category to show the entries for as my existing code uses {if hp-featured == "Yes"} but I can't see where I'd add this in your Nested tags PHP example – Jos Medinger Feb 24 '15 at 10:20
  • 1
    I'd suggest looking into Stash instead of using PHP. That article is 5 years old; best practices moved away from using PHP in your templates. – Low Feb 24 '15 at 11:26

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.