How to modify CodeIgniter 4 Pagination

Emmanuel

Administrator
Staff member
May 11, 2020
141
28
84
Today i was working on a project which am coding using the codeIgniter 4 framework and when i need to modify the look and setup a bootstrap styles for the pagination then i got stucked i searched google and couldn't find a good answer to this, which is what lead me to solving this issue on my own. to i will be showing you the simplest and best way to setup your pagination styles in codeIgniter for both $pager->links() and $pager->simplelinks();

but firstly i will like to say i really love and appreciate the company behind this great and impressive framework this new version 4 of the framework makes a lot of things simple and easy, with more option and chances for even a more shorter codes.


Please note i will be using codes from a current project so please read through before copying and paste

Code:
Please, Log in or Register to view codes content!
and in my shipment model am having

Code:
Please, Log in or Register to view codes content!
and in my view file am having


Code:
Please, Log in or Register to view codes content!

and after doing this i noticed my pagination is not setup using the popular bootstrap class and i have to solve this as this a something the customers won't like, no one likes to see something ugly you know, this lead me to a waste of time searching through Google as the solution provided in the user_guide even failed to work, even when you copy what's in the userguide and paste in your project you will end up with error, so to solve this issue of pagination i have to find the file responsible for the pagination and it leads me to this file.

root ->system -> Pager ->views.

this path contains 3 files of which i modified just 2 which are: default_full.php and default_simple.php.

in my default_full.php am now having this after modifying

Code:
Please, Log in or Register to view codes content!


and in my default_simple.php am having this please do modify to sweet your taste i just use the basic bootstrap class in my case

Code:
Please, Log in or Register to view codes content!


am sure by the time you do this you don't have to customize your pager always you just use the $page->links() and you automatically have the stylings.

Thanks for reading through please do drop you comments and opinions 👇