An alternate to paginator counter showing page in cakephp

An ordinary yet useful piece of hack to the way the cakephp pagination’s pages “showing page” parameter is displayed. As default, we are used to use $paginator->counter() method which gives us a counter string for the paged result set like “Showing page 1 of 3”. But in my latest project task i needed to show results set something like “Showing 1 to 20 of total 46”.

To display the result set like this, i wrote a few lines of code in my view using $paginator object values. Here are the lines of code which i place right under the $paginator->options() call:

And below is the line which i placed at the top of results table to read it like “Results 1 to 20 of total 46”:

I know this is a cheap hack but it really helped me when i had not much time left to deliver the work. I hope this helps someone else!

3 thoughts on “An alternate to paginator counter showing page in cakephp

Leave a Reply

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