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
I know this is old but found a simple solution that works for me. Add following in view file -
$paginator->options(array('url' => array_merge($this->passedArgs,
array('?' => ltrim(strstr($_SERVER['QUERY_STRING'], '&'), '&')))));
Found it here
I used Matyas solution, but for $keyword I did like this:
$queryString = explode('?', $_SERVER['REQUEST_URI']);
$options = array('url'=> array('controller' => 'post', 'action' => 'search', '?' => $queryString[1]));
To pass all URL arguments to paginator functions, add the following to your view: Plain Text View
$paginator->options(array('url' => $this->passedArgs));
That's it. See http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html
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 :)
$this->Paginator->options['url']['?'] = ['key' => $this->params['url']['value']];
Basically you can do it like this:
function list_results($keywords)
{
$data = $this->paginate('Posts', array('Post.title LIKE' => '%'.$keywords.'%'));
}