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.

entry limit not working with pagination

May 19, 2008 10:17am

Subscribe [2]
  • #1 / May 19, 2008 10:17am

    mdonohue

    19 posts

    I am building a catalog site.  On the thumbnail menu images pages I am using pagination and limiting the entries shown to 8, but it is not working.  When I don’t limit the number of entries it shows all of them correctly, but when I limit the number of entries to 8, every page is showing a different number of entries.

    Here is the code:

    <!-- start thumbnail list -->
        <ul class="thumbnail-list">
        {exp:weblog:entries weblog="products" disable="member_data|trackbacks" category="4"  orderby="url_title" sort="asc"  limit="8" paginate="top"}
    {if img-id =="1"}
              <li>
              <a href="http://{url_title_path=products/product_detail_2}">{site_url}images/ee_products/th/{title}.jpg</a>
              <a href="http://{url_title_path=products/product_detail_2}"><span>{item_name}</span></a>
              </li>
    {/if}
    {paginate}
                    <ul class="page-nav">
    {pagination_links}
                    </ul> <!-- end div - pages -->
    {/paginate}
         {/exp:weblog:entries}
         </ul>
    <!-- end thumbnail list -->

    Any help would be greatly appreciated.  Thanks

  • #2 / May 19, 2008 10:25am

    Andy Harris

    958 posts

    I think this might be a problem I had a while ago. The exp:weblog call generates the number of results you’re getting back and dumps that info to the screen - then you’re doing an {if} statement to filter out some of that data. The pagination doesn’t see your {if}, it’s just calculating based on the total results you’re getting back.

    I’ll look up how exactly I got around this and let you know. What does {if img-id =="1"} relate to?

  • #3 / May 19, 2008 10:31am

    mdonohue

    19 posts

    Thanks for the fast response.

    What does {if img-id =="1"} relate to?

    There are several views for each product, but we need only one view to show up in the thumbnail menu.  So if it has an img-id of 0 it doesn’t show up.  Should I set this as a category instead of a custom field?

  • #4 / May 19, 2008 10:38am

    Andy Harris

    958 posts

    Yes, that’s what I’d do - when dealing with pagination, I’ve found that any form of conditional logic inside the weblog tags causes a real headache, so if you can get your initial weblog:entries call to return exactly what you want to play with, you should be in business.

  • #5 / May 19, 2008 11:02am

    Robin Sowell

    13255 posts

    Yep- Andy nailed it.  You’re conditionally showing some entries- but the page count is based on the number of entries returned.  So- it always returns 8- but you only may show 5 or 6 or 8 or- whatever the conditional dictates.

    I’d use a category- or you can use the search paramter- but basically- something that only pulls back the entries you want.

  • #6 / May 19, 2008 11:19am

    mdonohue

    19 posts

    Thank you both for the help.  I used the search parameter and it works perfectly.  I’ve posted the new code below for anyone having the same problem.

    <!-- start thumbnail list -->
        <ul class="thumbnail-list">
        {exp:weblog:entries weblog="products"  search:img-id="=1" disable="member_data|trackbacks" category="4"  orderby="url_title" sort="asc"  limit="8" paginate="top"}
              <li>
              <a href="http://{url_title_path=products/product_detail_2}">{site_url}images/ee_products/th/{title}.jpg</a>
              <a href="http://{url_title_path=products/product_detail_2}"><span>{item_name}</span></a>
              </li>
    {paginate}
                    <ul class="page-nav">
    {pagination_links}
                    </ul> <!-- end div - pages -->
    {/paginate}
         {/exp:weblog:entries}
         </ul>
    <!-- end thumbnail list -->
  • #7 / May 19, 2008 11:29am

    Andy Harris

    958 posts

    No worries, I remember this being a particular pain.

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

ExpressionEngine News!

#eecms, #events, #releases