![]() |
How manage the segment error in the URI / pagination class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: How manage the segment error in the URI / pagination class (/showthread.php?tid=75716) |
How manage the segment error in the URI / pagination class - nicolas33770 - 03-09-2020 Good morning all, I have a question about the segments in the url. I'm currently making a contact list, and I'm using the pagination class. My url is like this: exemple.fr/contact/all/page/ By default I would like if a user loads the page: example.fr/contact/all/ it is redirected to example.fr/contact/all/1 is this possible? because I have an ArgumentCountError error when loading the page and I don't know how to catch this error. Thanks RE: How manage the segment error in the URI / pagination class - includebeer - 03-09-2020 Can you show some code and some error log? How do you do the redirection? Which function gives you the ArgumentCountError exception? RE: How manage the segment error in the URI / pagination class - nicolas33770 - 03-09-2020 Of course, thanks for your reply. This is my "all" method on my Contact Controller Code: /** My model Code: //Function to count all contacts On page view Code: <?php echo $this->pagination->create_links(); ?> When I select the first link or when I load https://exemple.com/contact/all/ I got this error. Quote:An uncaught Exception was encountered RE: How manage the segment error in the URI / pagination class - includebeer - 03-09-2020 Your function “all” have one parameter. If you go to /contact/all it expect a value for $startLimitResult and it is missing PHP Code: public function all($startLimitResult) If you want to be able to call this controller with no value, you need to define a default value like this: PHP Code: public function all($startLimitResult = 0) RE: How manage the segment error in the URI / pagination class - nicolas33770 - 03-09-2020 So simple, thanks. That's exactly what i was looking for, i still lack practice ... i think i may have found a bug. I set previous_link to false but the < still appear... ![]() Code: //Pagination class RE: How manage the segment error in the URI / pagination class - includebeer - 03-09-2020 (03-09-2020, 08:03 AM)nicolas33770 Wrote: i think i may have found a bug. I set previous_link to false but the < still appear... That’s because it’s prev_link, not previous_link! ![]() https://codeigniter.com/user_guide/libraries/pagination.html#customizing-the-previous-link RE: How manage the segment error in the URI / pagination class - nicolas33770 - 03-09-2020 Wouh My Mistake, sorry, and thanks for your help. It's working Thanks a lot |