How manage the segment error in the URI / pagination class |
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
Can you show some code and some error log? How do you do the redirection? Which function gives you the ArgumentCountError exception?
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
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)
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
(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/libra...vious-link
|
Welcome Guest, Not a member yet? Register Sign In |