Developer, entrepreneur, drummer, biker, dog owner, husband, and proud dad. Loves Laravel and coffee
CodeIgniter Pagination Library
Over the last few years I’ve been using my own version of pagination for CodeIgniter. The default one is pretty weak for my purposes, so I created one for all of my projects that has been very handy. There has been a number of posts on the CodeIgniter forums and their UserVoice account about updating their included pagination library, so I decided to share mine.
Drop everything into your application folder (assets folder is just for demo purposes)
Use: $config[‘uri_protocol’] = ‘PATH_INFO';
Go to the test controller and start working with it. You will have to make your own SQL queries/models.
Handles a directory structure or by using the $_GET array. (Ex: domain.com/users/5/ or domain.com/users/?page=5)
Directory structure can add a trailing slash or not, which is good for SEO (Ex: domain.com/users/5/ or domain.com/users/5)
Page 1 links will not show a pagination number. Search engines will look at domain.com/users/ and domain.com/users/1/ as duplicate content, so the pagination is dropped.
Handles regular links or AJAX update links
Automatically builds sorting links
Handles different HTML tags (li, div, etc) for pagination links and additional HTML/CSS options.
Handles additional search/sorting parameters and will add to the $_GET array