PHP Pagination Generator
I find this class to be quite useful: https://gist.github.com/gosukiwi/7715487
Basically, it generates an unordered list ul
with links to several pages, it's pretty cusomizable, it can output bootstrap style pagination markup, purecss markup, or any custom markup!
Here are some usage examples:
Generate PureCSS markup
$paginator = new Paginator();
$pagination = $paginator
->total(135) // total items to paginate
->per_page(10) // how many to show per page
->page_name('p') // ?p=1
->ul_class('pure-paginator') // css styles
->link_class('pure-button')
->link_active_class('pure-button-active')
->paginate();
Generate Bootstraps markup
$paginator = new Paginator();
$pagination = $paginator
->total(135)
->per_page(10)
->page_name('p')
->ul_class('pagination') // bootstraps only requires this
->paginate();
Written by Federico Ramírez
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#