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 in Search Not Working

October 18, 2012 10:22am

Subscribe [2]
  • #1 / Oct 18, 2012 10:22am

    Hello, I can’t get my pagination to work. The templates are not displaying the pagination content. Here is my code

    {exp:search:search_results}{!-- LOOP --}
    
         <h3><a href="http://{auto_path}">{title}</a></h3>
    
    <p>   {!--{excerpt}</p>
    
    <p>   <a href="http://{url_title_path}">read more…</a> --}</p>
    
    <p><br />
      <hr ></p>
    
    <p>{pagination_links}<br />
            <ul><br />
                    {first_page}<br />
                            <li><a href="http://{pagination_url}" class="page-first">First Page</a></li><br />
                    {/first_page}</p>
    
    <p>                {previous_page}<br />
                            <li><a href="http://{pagination_url}" class="page-previous">Previous Page</a></li><br />
                    {/previous_page}</p>
    
    <p>                {page}<br />
                            <li><a href="http://{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li><br />
                    {/page}</p>
    
    <p>                {next_page}<br />
                            <li><a href="http://{pagination_url}" class="page-next">Next Page</a></li><br />
                    {/next_page}</p>
    
    <p>                {last_page}<br />
                            <li><a href="http://{pagination_url}" class="page-last">Last Page</a></li><br />
                    {/last_page}<br />
            </ul><br />
    {/pagination_links} <br />
        </p>
    
    <p> {/exp:search:search_results}{!-- /LOOP --}


    It displays this on the rendered page:

    {pagination_links}
    {first_page}
    First Page
    {/first_page} {previous_page}
    Previous Page
    {/previous_page} {page}
    {pagination_page_number}
    {/page} {next_page}
    Next Page
    {/next_page} {last_page}
    Last Page
    {/last_page}
    {/pagination_links}

     

  • #2 / Oct 18, 2012 10:35am

    Also, the above didn’t work when I wrapped {pagination_links} with {paginate}

  • #3 / Oct 18, 2012 11:33am

    Ok, I figured out the problem.

    We are using the query module and so the pagination wasn’t working inside of that. I have to see if we can figure out a way around that though.

    Issue is pagination and {exp:query} tags.

  • #4 / Oct 19, 2012 11:43pm

    Lisa Wess

    20502 posts

    Hi, capstonedesigngroup -

    Can you show us your actual code? Both the search module and the query module can paginate, so I suspect your tags are simply confused.  Usually the best way to get around this is to embed a tag, but it will depend on what your accomplishing with that query.

    A bit more code would help us to help you.

    Thank you!

  • #5 / Oct 20, 2012 7:06am

    Hi Lisa,

    We found what was causing the issue. This is what we had going on… We had the search results displaying within a query tag. So it looked something like:

    {exp:query}

    —html code here

    {exp:search:search_results}

    —Search results code here—

    {paginate}
    —Paginate code here—
    {/paginate}

    {/exp:search:search_results}

    —html code here

    {/exp:query}

    When I used your pagination example, copied directly from the website, {pagination_links} didn’t work properly. But when I put {paginate} in it’s most simple way, it did display pagination. However, the pagination showed up after the {/exp:query} tag and NOT directly after the search results tag, which is where I wanted it. I hope that makes sense.

    Thanks

  • #6 / Oct 22, 2012 1:16am

    narendra

    44 posts

    Hi,

    I am facing the same problem. Pagination not working and EE tags shown in front end for pagination. Structure like this,

    {exp:query limit="10" paginate="bottom" sql="SELECT ct.entry_id
        FROM exp_channel_titles AS ct
        WHERE ct.site_id = 1 AND ct.channel_id = 1 AND ct.status != 'closed'
        GROUP BY ct.entry_id
        ORDER BY ct.entry_date DESC
        "}
        {exp:channel:entries channel="products" dynamic="on" entry_id="{entry_id}"}
        {title}
            {pagination_links}
            <ul>
              {first_page}
              <li><a href="http://{pagination_url}" class="page-first">First Page</a></li>
              {/first_page}
              
              {previous_page}
              <li><a href="http://{pagination_url}" class="page-previous">Previous Page</a></li>
              {/previous_page}
              
              {page}
              <li><a href="http://{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
              {/page}
              
              {next_page}
              <li><a href="http://{pagination_url}" class="page-next">Next Page</a></li>
              {/next_page}
              
              {last_page}
              <li><a href="http://{pagination_url}" class="page-last">Last Page</a></li>
              {/last_page}
            </ul>
            {/pagination_links} 
        {/exp:channel:entries}
    {/exp:query}

    Is anything wrong here?

    Thanks

  • #7 / Oct 22, 2012 11:54am

    Lisa Wess

    20502 posts

    Narendra -

    You would be best to try embedding the inner channel entries tag and passing your query information to it through the embed.  That way the pagination conflict between the two tags isn’t there.

    capstonedesigngroup -

    Your case is harder because of the search results.  You can try the embed route, but I’m not sure it will work.  What does your query accomplish? There may be a better approach we can discover together.

  • #8 / Nov 02, 2012 3:48am

    narendra

    44 posts

    Hi Lisa,

    Thanks for reply.

    I am not getting what do you mean?

    Do you mean, exp:channel code add in another template and embed between exp:query?

    Than, do we need to add limit parameter in exp:channel (and remove from exp:query)?

    thanks

  • #9 / Nov 06, 2012 2:00pm

    Kevin Smith

    4784 posts

    Hi Narendra,

    What Lisa was recommending was to put the Channel Entries tag in its own template, and then embed that template inside the Query module tags, using the entry_id output by the Query module as an embed variable. Since the Query module tags and Channel Entries tags will be rendered in separate templates, there wouldn’t be a pagination conflict. Does that makes sense?

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

ExpressionEngine News!

#eecms, #events, #releases