0
votes

I am working on an Expression Engine site and am trying to fix a bug with pagination. A user performs a search which displays paginated results. The search terms are in a query string, so all I need to do is include the query string in the pagination links. However, I don't know how to configure this in Expression Engine. This is all I have to work with:

{paginate}
  <div class="results-pager">
    Page {current_page} of {total_pages} pages {pagination_links}
  </div>
{/paginate}

Can I pass some sort of option to {pagination_links} to include the query string in the links it generates? Or do I need to write this code myself?

2
Also, there is an EE StackExchange site: expressionengine.stackexchange.com - Anna_MediaGirl
Ah thanks! Didn't realize that. =] - Andrew

2 Answers

1
votes

I found a way to do it. If you enable PHP code in your templates, you can manually recreate the pagination_links functionality and include the query string in the generated links.

Replace this:

{pagination_links}

With this:

{if total_pages > 1}
  <div class="pagination">
    {pagination_links}
      {first_page}<a href="{pagination_url}?<?php echo $_SERVER['QUERY_STRING'] ?>">&lsaquo; First</a>{/first_page}
      {previous_page}<a href="{pagination_url}?<?php echo $_SERVER['QUERY_STRING'] ?>">&lsaquo; Prev</a>{/previous_page}
      {page}
        {if current_page}
          <strong>{pagination_page_number}</strong>
        {if:else}
          <a href="{pagination_url}?<?php echo $_SERVER['QUERY_STRING'] ?>">{pagination_page_number}</a>
        {/if}
      {/page}
      {next_page}<a href="{pagination_url}?<?php echo $_SERVER['QUERY_STRING'] ?>">Next &rsaquo;</a>{/next_page}
      {last_page}<a href="{pagination_url}?<?php echo $_SERVER['QUERY_STRING'] ?>">Last &rsaquo;</a>{/last_page}
    {/pagination_links}
  </div>
{/if}
0
votes

You might take a look at this free add-on:

http://devot-ee.com/add-ons/better-pagination

Not sure it's the exact fit for what you're doing though, it might allow you to do what you want without turning PHP on.