Thursday, February 19, 2015

Re: how can i return to page with same search filters

IMO you shouldnt reinvent the wheel (with design flaws in it), but re-use best practice approaches via plugin form that have been working
for many years with ease:
https://github.com/CakeDC/search is the de facto standard for easy filtering of your paginated data

Mark


Am Donnerstag, 19. Februar 2015 15:02:10 UTC+1 schrieb ajt:
Hi,

In cakephp I can add search filters and change the post vars into Get as below. This works fine. My problem is how do go to another page found from the list of searches and return to the same page? All search filters are gone when i return as I am not storing them.

eg I search for invoice 2 and get a list of searches. i click on link from the search and view a page. I then want to return to the same page with same page number for invoice 2?

if (($this->request->is('post') ||$this->request->is('put'))&& isset($this->request->data['filter'])) {

       $filter_url['controller'] = $this->request->params['controller'];         $filter_url['action'] = $this->request->params['action'];         $filter_url['page'] = 1;    // for each filter we will add a GET parameter for the generated url  foreach($this->data['Filter'] as $name => $value){     if($value){         $filter_url[$name] = urlencode($value);     }  }     //Post params are now GET paramaters  return $this->redirect($filter_url);         }//isset   

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: