Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP pagination and the get parameters

Tags:

php

cakephp

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 like domain.com/search/page:x, so in the next and prev and numbers page the get parameter is lost. I need to configure paginator to get links like domain.com/search/page:x/?s=keyword But I can't do this.

I need to know how to configure

$paginator->options();
$paginator->next();
$paginator->prev();
$paginator->numbers();

to get the needed efect. Thanx.

like image 714
Jos Avatar asked Feb 24 '10 11:02

Jos


People also ask

How to use pagination in CakePHP?

CakePHP eases the burden on the developer by providing a quick, easy way to paginate data. Pagination in CakePHP is offered by a component in the controller. You then use View\Helper\PaginatorHelper in your view templates to generate pagination controls.

What does it mean to paginate a document?

Pagination is the process of separating print or digital content into discrete pages. For print documents and some online content, pagination also refers to the automated process of adding consecutive numbers to identify the sequential order of pages.


1 Answers

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 :)

like image 93
Matyas Avatar answered Oct 27 '22 13:10

Matyas