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

Written by James McDonald

March 6, 2015

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 *

You May Also Like…

How to Research a CPU Upgrade

How to Research a CPU Upgrade

Upgrade Time! Doing a lot of VMWare Workstation virtualization to create labs for self-study and training. Finding...