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 not working with category_url_title

April 25, 2011 12:44pm

Subscribe [2]
  • #1 / Apr 25, 2011 12:44pm

    forloops

    3 posts

    Hello everyone, I apologize in advance if this has been answered, but I could not find a solution in the forum while searching…

    I am having trouble displaying my pagination results while using this code. The results show up fine, however once I put a limit, the pagination does not show up at all. Am I missing something?

    Any suggestions are greatly appreciated.

    Thanks!


    Template: programs/index

    {if segment_2 == "by_type"}
        {embed="programs/brief_details"}
    {/if}
    
    
    
    {if segment_2 == "by_region"}
        {embed="programs/brief_details"}
    {/if}
    
    
    {if segment_2 == "by_group"}
        {embed="programs/brief_details"}
    {/if}

     


    Template: programs/brief_details

    {exp:query sql="SELECT cat_id, cat_name, cat_image FROM exp_categories WHERE cat_url_title = '{segment_3}' LIMIT 0,1"}
        
        {!-- Category Image --}
        {if cat_image}{cat_image} 
    
    {/if}
    
    
        {!-- Category Title --}
        <h1>{cat_name} Programs</h1>
    
        
            
        
        
        {!-- Get entries for category selected --}
        {exp:channel:entries channel="programs" category="{cat_id}" orderby="program_sort|title" sort="desc" limit="4" paginate_base="programs/{segment_2}/{segment_3}" paginate="bottom"} 
              
            {if program_image_small}{program_image_small}{/if}
      
            {if website} 
                <h2><a href="http://{website}" title="{title}">{title}</a></h2>
    
    <p>        {if:else} <br />
                </p><h2><a href="http://{path=%27program/{url_title}%27}" title="{title}">{title}</a></h2>
    
    <p>        {/if}<br />
            <br />
            {brief_description} <br />
            <br />
            <br />
            </p>
    
    <p>        <br />
            {!-- Pagination --}<br />
            {paginate}{if {total_pages} > 1}  Page {current_page} of {total_pages} pages {pagination_links}  {/if}{/paginate}<br />
            <br />
            <br />
            {if no_results}<h2 align="center">No Results</h2>{/if}<br />
        {/exp:channel:entries}<br />
     <br />
    {/exp:query}

  • #2 / Apr 25, 2011 6:56pm

    Brandon Jones

    5500 posts

    Hi forloops,

    Take a look at the Pagination section of the Query Module’s documentation. Does that help?

  • #3 / Apr 25, 2011 8:28pm

    forloops

    3 posts

    Hi Brandon, Thanks for replying.

    I did take a look at the user guide and noticed that LIMIT needed to be passed in as a parameter when using exp:query, however I am trying to use pagination on the query inside.


    In my outer query:

    {exp:query LIMIT="1" sql="SELECT cat_id, cat_name, cat_image FROM exp_categories WHERE cat_url_title = '{segment_3}'"}

    I am grabbing the category_url_title from the URL and running a query to get the category_id of it to narrow down my results for the second query:

    {exp:channel:entries channel="programs" category="{cat_id}" orderby="program_sort|title" sort="desc" limit="4" paginate_base="programs/{segment_2}/{segment_3}" paginate="bottom"}


    The results do show up fine. I set the limit to 4, and it only shows 4, but the pagination does not show up even though there are more than 4 results.

    I’m basically trying to use the URL to filter through my programs channel like so:

    /programs/by_type/adoption
    /programs/by_region/south
    /programs/by_county/cook_county
    /programs/by_group/children


    The 3rd segment is the category_url_title.


    I’ve also tried to setup separate templates for “by_type”, “by_region”, “by_group”, “by_county”, however pagination still does not work even though it is showing the correct entries, just not paginated.

  • #4 / Apr 26, 2011 4:25pm

    Brandon Jones

    5500 posts

    Let’s simplify. Does pagination work correctly if you remove the outer query module tag, use just exp:channel:entries and hardcode the category id? Also, what version and build of EE are you using?

  • #5 / Apr 26, 2011 5:05pm

    forloops

    3 posts

    I am running Build: 20101220

    If I remove the outer query and hard code the category id, it works just fine.

  • #6 / Apr 27, 2011 3:59pm

    Brandon Jones

    5500 posts

    Ah, OK. I suspect the Channel module’s pagination just doesn’t have knowledge of the outer query, and so can’t paginate correctly. Unfortunately you may need to work around this limitation; I’d suggest trying to pull the relevant data using the Query module alone. Would that work?

  • #7 / May 02, 2011 1:08pm

    forloops

    3 posts

    I am not familiar with the query module - more specifically, I don’t have enough knowledge of EE to put together a query that can accomplish this. Can you help me with that?

  • #8 / May 02, 2011 7:05pm

    Brandon Jones

    5500 posts

    Hi forloops,

    Unfortunately we can’t specifically support custom queries, but EE’s data is stored logically. You’ll want to use a JOIN or two to line up exp_categories with exp_channel_data. If you’d like I’ll move this over to Community Help to get you further input.

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

ExpressionEngine News!

#eecms, #events, #releases