Losing URI segments when paginating with CodeIgniter

Posted by Danny Herran on Stack Overflow See other posts from Stack Overflow or by Danny Herran
Published on 2010-06-11T04:40:41Z Indexed on 2010/06/11 4:42 UTC
Read the original article Hit count: 300

Filed under:
|
|
|
|

I have a /payments interface where the user should be able to filter via price range, bank, and other stuff. Those filters are standard select boxes. When I submit the filter form, all the post data goes to another method called payments/search. That method performs the validation, saves the post values into a session flashdata and redirects the user back to /payments passing the flashdata name via URL.

So my standard pagination links with no filters are exactly like this:

payments/index/20/
payments/index/40/
payments/index/60/

And if you submit the filter form, the returning URL is:

payments/index/0/b48c7cbd5489129a337b0a24f830fd93

This works just great. If I change the zero for something else, it paginates just fine. The only issue however is that the << 1 2 3 4 >> page links wont keep the hash after the pagination offset. CodeIgniter is generating the page links ignoring that additional uri segment.

My uri_segment config is already set to 3:

$config['uri_segment'] = 3;

I cannot set the page offset to 4 because that hash may or may not exists. Any ideas of how can I solve this? Is it mandatory for CI to have the offset as the last segment in the uri? Maybe I am trying an incorrect approach, so I am all ears.

Thank you folks.

© Stack Overflow or respective owner

Related posts about php

Related posts about codeigniter