Implementing <<first and last>> links in cakephp pagination

I don't know why they…

Login

Blog History

I don't know why they don't include them by default but here is an example of how to add first and last links to your view.

<?php
    echo $this->Paginator->first('<< first'); #add this
    echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
    echo $this->Paginator->numbers(array('separator' => ''));
    echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
    echo $this->Paginator->last('last >>'); # add this
?>

You probably want to look at the css classes that you should apply too.

Of course there are alot more options as with most things you can read the documentation to find out more: http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html

Another option is to use the 'first' and 'last' options to the numbers method

<?php
	echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
	echo $this->Paginator->numbers(array('separator' => '', 'last' => "last", 'first' => "first"));
	echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>

 

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.