How to mantain POST data when using pagination in CI |
[eluser]ReyPM[/eluser]
Hi, I'm trying to paginate results in a search form but I lost the parameter when pass from one page to another using pagination class. My code is as follow: controller Code: public function ajaxsearch($start = 0) { and the model associated is: Code: function AjaxSearch($keywords, $end, $start) {
[eluser]Glazz[/eluser]
Maybe you need to append the data you don't want to lose while paginating in the $config['base_url'] variable..
[eluser]ReyPM[/eluser]
I don't want this because then could be changed and could be a security issue for my application
[eluser]ReyPM[/eluser]
I think in that solution but let me ask something, I have previous session created with data if I do this: Code: $search_data = array('keyword' => $this->input->post('keyword', TRUE)); Cheers
[eluser]ReyPM[/eluser]
Answer myself: the previous session data isn't lost. I found a great solution at this page: http://www.andyhawthorne.co.uk/how-to-pa...niter-2-1/ hope others can use it too. @Glazz thanks for you time
[eluser]Glazz[/eluser]
No, i don't think so, you just need to be sure that you don't overwrite your other session variables. For example: Code: $test = array( If you do this: Code: $test = array( So the session variable was overwritten, if you know what i mean..
[eluser]skunkbad[/eluser]
I have a full working example of a paginated search in Community Auth. It uses ajax though, and does not fall back to a non-js solution.
[eluser]jellysandwich[/eluser]
There's another option you should consider: using GET instead of POST. Searches are typically "safe", so it's okay to use GET because you don't need to worry about users performing destructive actions. If you use GET, it will be much easier to maintain and control the states (i.e., pagination). Not only that, but users can bookmark the searches and come back to it easily. Also, users won't need to deal with the annoying "Are you sure you want to resubmit?" popups when they refresh. Personally, this is one of my biggest peeves. See more here: http://stackoverflow.com/questions/46585...ou-use-get |
Welcome Guest, Not a member yet? Register Sign In |