ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Javascript messing with limit & sorting

July 23, 2012 6:35pm

Subscribe [3]
  • #1 / Jul 23, 2012 6:35pm

    The Design Core

    359 posts

    I have some javascript that hides entries based on the lack of certain content.

    The code looks like this:

    [removed]
    $(document).ready( function() {
       $('#content #main .wrap .col .feature_block').each(function(index, el) {
          if ($(el).children(".feature_block_content").children().size() == 0 )
            $(el).hide();
      });
    });
    [removed]

    It works great until I try to set orderby=“date”, sort=“desc” & limit=“2” then things get weird. The limit makes no entries appear at all.

    The template code looks like this:

    {exp:channel:entries  
                channel="tenants"          
                disable="categories|category_fields|member_data|pagination|trackbacks" 
                cache="yes" 
                refresh="1440"
                orderby="date"
                sort="desc"
         limit="2"
                dynamic="off"
              }
    
              <div class="feature_block clear">
    
    {exp:imgsizer:size src="{logo}" width="130"}
    {sized}
    {/exp:imgsizer:size}
    
    
              <div class="feature_block_content">
    
              {exp:channel:entries  
                channel="offers"          
                disable="categories|category_fields|member_data|pagination|trackbacks" 
                cache="yes" 
                refresh="1440" 
                orderby="date"
                sort="desc"
                dynamic="off"
              }
    
                {if "{embed:tenant_id}" == "{related_entries id='offer_tenant'}{entry_id}{/related_entries}"}
                  <a href="http://{title_permalink=%27offers/detail%27}" class="">{title}</a>
                  
                                                    
                {/if}
           
              {/exp:channel:entries}
    
              </div>
    
    
              </div>
    
              {/exp:channel:entries}

    Any ideas what could be going on here?

    Thanks for any help.

  • #2 / Jul 23, 2012 8:42pm

    John St-Amand

    865 posts

    I could be wrong, but it looks like you’ve nested an entries loop inside of another entries loop - which is something EE doesn’t support.  That may in fact be the source of the issue.  The only way you can nest entries loops is for the inner one to be contained in an embedded template (which brings with it a performance cost, but it gets you around the loop within a loop limitation).

  • #3 / Jul 23, 2012 8:52pm

    The Design Core

    359 posts

    The inner loop is actually in an embed.

    I just pulled it out of the embed for the example in my post.

    Sorry. Probably should have mentioned that.

  • #4 / Jul 25, 2012 11:47am

    the3mus1can

    426 posts

    Not sure if this will fix your other issues, but just looking at the template code briefly it looks like that inner loop could be replaced by a reverse_related_entries tag.  If it can be it would be a lot better for performance. No embed inside a loop and no extra data pulled back in the inner entries loop.  It might also have the added benefit of fixing the other problem.

  • #5 / Jul 25, 2012 3:27pm

    The Design Core

    359 posts

    Thanks for the tip!

    Is there any way to hide the parent if there are no reverse_related_entries without using that javascript?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases