Pagination Problem |
[eluser]CodeIgniterNewbie[/eluser]
I do not want to use URI segments for my pagination (as I have a lot of possible parameters to pass in unknown order). Currently, I have $config['enable_query_strings'] = FALSE;, and if I set it to TRUE, I get something like this (from CI's example): http://example.com/index.php?c=test&m=page&per_page=20 Where "c" is the controller, "m" is the method, etc. This is NOT what I want. I want something like this: http://domain.com/?min_amount=100&max_am...offset=100 Is there a way to achieve this in CI? If not, is there some library already available that I can use?
[eluser]yacman[/eluser]
Enabling query strings is not what you want to do. All you need to do to access GET variables in your controller is: Code: function index() {
[eluser]CodeIgniterNewbie[/eluser]
Hi yacman, can you please show me how you would initialize the pagination class to get the output I need? Thanks.
[eluser]yacman[/eluser]
Don't copy and paste this because it probably won't work, but it's a start: Code: function index() {
[eluser]CodeIgniterNewbie[/eluser]
yacman, I've simplified your code: Code: // configure the paginator Notice the problems (see comments). The problem is that the GET params such color and size aren't in the URL.
[eluser]yacman[/eluser]
Add each paramater you wish to persist in the Pagination links onto the $config['base_url'] .
[eluser]CodeIgniterNewbie[/eluser]
Ah, so something like this: Code: $config['base_url'] = base_url() . 'search/?' . http_build_query($_GET, '', '&'); Just make sure the $_GET array does not have "per_page" in it because the pagination library will handle that?
[eluser]CodeIgniterNewbie[/eluser]
yacman, I think I'm still confused. Please take a look at the following code in a controller named "test": Code: $this->load->library('pagination'); Then go to: test/?name=foo The resulting pagination links look correct. But when you click on, say, link number "2", you are redirected to Code: ?name=foo&per_page=20 Code: ?name=foo&per_page=20&per_page=40 What's going on? |
Welcome Guest, Not a member yet? Register Sign In |