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.

Pagination With exp:query

August 18, 2010 4:03pm

Subscribe [3]
  • #1 / Aug 18, 2010 4:03pm

    ROCKET MEDIA

    153 posts

    I need to paginate results coming from a custom query using exp:query.

    The code I have follows the documentation but does not work. I am not using “limit” in the query as instructed in the docs.

    What am I doing wrong?

    {exp:query 
    limit="25" 
    paginate="both" 
    sql="(query)"}{/exp:query}
  • #2 / Aug 18, 2010 4:32pm

    Ingmar

    29245 posts

    Can you show us a little more of your query? Also, what version and build of EE are you using?

  • #3 / Aug 19, 2010 12:17pm

    ROCKET MEDIA

    153 posts

    This is the entire query. I am using 1.6.7 /B 20090320

    {exp:query 
    limit="25" 
    paginate="both" 
    sql="
    SELECT
    t.title,
    t.url_title AS permalink,
    t.entry_id AS entry_id,
    d.field_id_32 AS phone_foodbank,
    d.field_id_46 AS crossstreets_foodbank,
    d.field_id_33 AS hours_foodbank,
    d.field_id_47 AS languages_foodbank,
    d.field_id_36 AS eligibility_foodbank,
    d.field_id_31 AS zipcode_foodbank
    
    FROM 
    exp_weblog_data AS d, 
    exp_weblog_titles AS t, 
    exp_category_posts AS c 
    
    WHERE t.weblog_id = '14' 
    
    AND t.entry_id = d.entry_id
    AND t.entry_id = c.entry_id
    
    {if embed:listcat != ''}AND c.cat_id IN ({embed:listcat}) {/if}
    {if embed:listzip != ''}AND d.field_id_31 = '{embed:listzip}' {/if}
    {if embed:listcity != ''}AND d.field_id_40 = '{embed:listcity}' {/if}
    
    GROUP BY t.entry_id
    "}{/exp:query}
  • #4 / Aug 19, 2010 8:44pm

    Brandon Jones

    5500 posts

    Hi RocketMedia,

    I’m not seeing the {paginate} tag pair in that code - perhaps you left it out? In any case I’d strongly recommend upgrading to 1.6.9 when possible so that we’re on the same page.

  • #5 / Aug 24, 2010 2:06pm

    ROCKET MEDIA

    153 posts

    I have the standard pagination code inside the query. I will upgrade to 1.6.9 and see if that helps.

    {paginate}
    Page {current_page} of {total_pages} pages {pagination_links}
    {/paginate}
  • #6 / Aug 24, 2010 3:12pm

    Ingmar

    29245 posts

    Very good. Let us know how you get on, please.

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

ExpressionEngine News!

#eecms, #events, #releases