2

I've been having problems getting the first_page and last_page pagination links to work correctly. I then spotted a user comment in the docs that said they only appear if there's four or more pages (though I hoped this just applied to the auto-generated pagination_links variable). I'm trying to output them at all times and thought the pagination variables would give me that flexibility.

I've inserted my code below - can anyone see if I'm doing anything wrong here? Or is there another way to be going about this? Or is it by design or a bug that the first_page and last_page only work when there's four or more pages? The links do indeed work when there's 4 or more pages.

{paginate}
  {pagination_links}
    <div class="search-pagination">
      <ul>
        <li class="first"><a href="{first_page}{pagination_url}{/first_page}">First</a></li>
        <li class="prev"><a href="{previous_page}{pagination_url}{/previous_page}">Previous</a></li>
        <li class="page-info">Page {current_page} of {total_pages}</li>
        <li class="next"><a href="{next_page}{pagination_url}{/next_page}">Next</a></li>
        <li class="last"><a href="{last_page}{pagination_url}{/last_page}">Last</a></li>
      </ul>
    </div><!--search-pagination-->
  {/pagination_links}
{/paginate}
0

Try a conditional like this:

{if next_page}
    CODE
{if:else}
    CODE
{/if}

If that doesn't work, you'd need to hack the \system\expressionengine\libraries\EE_Pagination.php file.

Or take a look at some of the pagination addons on Devot-EE.

1
  • 1
    The problem is that the code itself for first_page and last_page generates nothing unless there's at least four pages, so even if you stick it within conditionals, it outputs nothing within them. I'm classing this as a bug, and a hang-over from the pagination_links single variable behaviour. I've filed a bug report here: support.ellislab.com/bugs/detail/19221 Think the pagination add-ons is the way to go for now, thanks.
    – Stephen
    Feb 19 '13 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.