![]() |
Tutorial for creating custom Bootstrap 4 pagers and page numbers - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34) +--- Thread: Tutorial for creating custom Bootstrap 4 pagers and page numbers (/showthread.php?tid=77274) |
Tutorial for creating custom Bootstrap 4 pagers and page numbers - InsiteFX - 08-10-2020 In this quick tutorial I will show you how to create two Bootstrap 4.5.2 Custom Pagers, I will also show you how to create a Bootstrap Button to display the current page of total pages. So lets get started. NOTE: I will be using a dummy controller just to show you how we pass the data to the view. 1) Create a blank PHP file called view_data.php in the Views folder, this is just to pass the data to all views. 2) We need our two custom Bootstrap 4 pager templates. These will be placed in the Views folder under Pagers. Views/Pagers/ bs_full.php bs_simple.php -------------- Code for the bs_full.php PHP Code: <?php Code for the bs_simple.php PHP Code: <?php 3) We need to edit the app/Config/Pager.php file to add our two custom pagers. PHP Code: public $templates = [ 4) Here in the controller we are getting the pager current page (getCurrentPage) and total pages (getPageCount). We are passing these to a pagination view. PHP Code: /** 5) The pagination view file. The top part is the type of pager we want to use and the bottom part displays the Page 1 of 4 total pages. PHP Code: <!-- Pagination --> You can use this pagination view in layouts etc; That's all there is to it so good luck and I hope you find these useful. RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - MGatner - 08-10-2020 Great tutorial! I do mostly the same thing in all my projects. Thanks for sharing this! RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - obstbude - 08-10-2020 This is really helpful. Thanks for that. |