![]() |
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) Pages:
1
2
|
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. RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - remesses_thegreat - 04-18-2023 Thanks a million saved my day. Codeigniter Rocks! RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - remesses_thegreat - 04-18-2023 (04-18-2023, 10:28 AM)remesses_thegreat Wrote: Thanks a million saved my day. Codeigniter Rocks! So just ran into a small problem that i dont see mentioned in the comments. So i have a one page website with multiple Popup modals and a lot of paging needs to happen. So managed to get it right on the first tab, And it looks and works great. The moment i copy the same code and implement on the second tab there it behave abnormally. So i thought maybe its the variable so i changed them so they are not exactly the same. What is it that i am suppose to change if using one page to display multiple records on different tabs and modals RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - InsiteFX - 04-18-2023 You need to use grouping. CodeIgniter 4 User Guide - Library Reference Pagination - Paginating Multiple Results RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - remesses_thegreat - 04-19-2023 (04-18-2023, 11:00 PM)InsiteFX Wrote: You need to use grouping. Thanks, Works as expected with the help of javascript to maintain active tab. RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - remesses_thegreat - 04-19-2023 (04-18-2023, 11:00 PM)InsiteFX Wrote: You need to use grouping. I'm really sorry to bother you. Never done this and its going over my head. Not sure what I'm doing wrong. So i tried it with the first two groups it worked fine. The moment i added other group it only returns one page of each. Here is my code maybe I'm doing it wrong. I have a lot of data being rendered onto just one page. I know it maybe stupid but honestly dont know what i need to change PHP Code: $data = [ RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - InsiteFX - 04-19-2023 You need unique group# you have multiple groups with the same group number. RE: Tutorial for creating custom Bootstrap 4 pagers and page numbers - remesses_thegreat - 04-19-2023 (04-19-2023, 02:50 AM)InsiteFX Wrote: You need unique group# you have multiple groups with the same group number.I named them group 1-11 without duplicating for each call to the database. The only place that has duplicates is the currentPage and totalPages as i thought they should use the associated group name same as the tutorial. I just changed curentPage to vcurrentPage or appcurrentPage. |