CI Pagination Helper - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CI Pagination Helper (/showthread.php?tid=11907) |
CI Pagination Helper - El Forum - 09-28-2008 [eluser]ray73864[/eluser] I must be thick or something as i can't seem to get the pagination helper to work, mind you, the user guide is very vague on how to make it work too. This is the function i am trying to paginate (i haven't started using models yet, so it is a bit long): Code: function products($categoryid = 0, $page = 10) and in my view i am doing: <?= $links; ?> I have almost 5000 records in the database table, and removing the limit causes the browser to hang, so i really need the pagination to work. CI Pagination Helper - El Forum - 09-28-2008 [eluser]Sarfaraz Momin[/eluser] I see a potential issue with your code. The base_url you are using are having only 2 segments so it would be 3rd segment having the pagination info. The config you are using for uri_segment is 4 which is incorrect. Can you fix that and check. Lemme know the outcome and also whats the result. Have a good day !!! CI Pagination Helper - El Forum - 09-28-2008 [eluser]ray73864[/eluser] ok, so i have moved to a model for it, and done a couple of other things. however the pagination still isn't working and i am not getting the links part. The new code is: Controller Function: Code: function products($page = 0) Model Function: Code: function getProducts($num, $offset, $category = 0) The view hasn't changed CI Pagination Helper - El Forum - 09-28-2008 [eluser]ray73864[/eluser] [quote author="Sarfaraz Momin" date="1222602712"]I see a potential issue with your code. The base_url you are using are having only 2 segments so it would be 3rd segment having the pagination info. The config you are using for uri_segment is 4 which is incorrect. Can you fix that and check. Lemme know the outcome and also whats the result. Have a good day !!![/quote] The uri segment was fine in the first listing, 'admin_catalogue' was the controller and 'products' was the function, so segment 3 would have been 'category' (assuming it was passed) which means that 'page' would have been segment 4. CI Pagination Helper - El Forum - 09-28-2008 [eluser]ray73864[/eluser] ok, so i worked out what the problem was, the problem was that the 'num_rows' was being set to $query->num_rows(), but since the query was being limited the pagination class was only ever going to see 1 page of results and never anymore. i created a new function in my model to count all the results that match the query (minus the limiter) and now the page links all come up properly. |