CakePHP pagination and the get parameters

前端 未结 8 570
逝去的感伤
逝去的感伤 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:08

    create the options array

    $options = array(
        'url'=> array(
            'controller' => 'posts', 
            'action' => 'search', 
            '?' => 'keyword='.$keyword
         )
    );
    

    set it to the helper

    $paginator->options($options)
    

    and then you can use the paginator helper while retaining the GET variables.

    hope that it helped :)

    to make it easier you can putl $paginator options in your view or .ctp file

    $this->Paginator->options['url']['?'] = $this->params['ur];
    

    then put the value that you want :)

提交回复
热议问题