CakePHP pagination and the get parameters

前端 未结 8 562
逝去的感伤
逝去的感伤 2021-02-02 02:31

I have a problem with the pagination in my search page. When a user search something I have a url like domain.com/search/?s=keyword but paginator gives me links lik

相关标签:
8条回答
  • 2021-02-02 03:15

    use statement in your view for pass parameters while pagination

    $paginator->options(array('url' => $this->passedArgs));
    

    this is simplest way to pass parameters.

    Some time $this->passedArgs not working at that time pass static value at there and try with that static value.

    $paginator->options(array('url' => array('a', 'b'))); 
    
    0 讨论(0)
  • 2021-02-02 03:19

    Check this comment.

    I used it, it works fine.

    in app_controller file:

    function _paginatorURL() {
      $passed = "";
      $retain = $this->params['url'];
      unset($retain['url']);
      $this->set('paginatorURL',array($passed, '?' => http_build_query($retain)));
    }
    
    function beforeFilter()
    {
      $this->_paginatorURL();
    }
    

    in views file:

      <?php $paginator->options = array( 'url' => $paginatorURL );?>
    

    Hope it helps.

    0 讨论(0)
提交回复
热议问题