Hey Folks, I have got paginating search results working...PERFECTLY!!!  Took
me long enough...anyway, I would like the have the pagination remember the
filter terms (as it currently does) without having to make any modifications
to the view.

The code is here and listed a cakephp's bin (URL below):

VIEW: this line makes the pagination URLs contain filters I need
<?php $paginator->options(array('url' => $this->passedArgs));?>
 
I want to remove the line above and get it in the controller and am combing
the internets for an answer....many thanks.
 
CONTROLLER
    function index() {
        $this->UserAction->recursive = 0;
 
        // holds the keyword filter
        $filter = "";
        // holds the conditions that should filter by
        $conditions = array();
 
        // filter by the data that is in the url string
        if(isset($this->passedArgs['param_filter'])){
            $filter = $this->passedArgs['param_filter'];
        }
 
        // filter by the data in the form field
        if($this->data['UserAction']['filter']){
            $filter = $this->data['UserAction']['filter'];
        }
 
        // set the data from the form field as something that will be in the
url
        // so when URLs are constructed on the view, the filter will be
there
        $this->passedArgs['param_filter'] = $filter;
 
        // do we have data to filter by
        if($filter){
            // if so, let's add this to the conditions array
            $conditions = array("UserAction.action = '$filter'");
        }
 
        // pagination criteria to filter by
        $this->paginate['UserAction'] = array(
                    'limit' => 10,
                    'order' => array ('UserAction.id' => 'asc'),
                    'conditions' => $conditions
                    //'url' => array ('url' => 'testme')
                );
 
        // the result sets
       $this->set('userActions', $this->paginate());
        // pass the paramters to the view
        $this->set('param_filter', $filter);
 
         }

http://bin.cakephp.org/view/602487164 http://bin.cakephp.org/view/602487164 
-- 
View this message in context: 
http://www.nabble.com/Paginating-search-results%2C-keeping-search-criteria%2C-and-not-messing-with-the-view-tf4899190.html#a14032399
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to