开发者

Redirecting paginator->sort to the first page in Cakephp

开发者 https://www.devze.com 2022-12-19 19:30 出处:网络
How do I do a paginator sort and also specify it to go to the first page: echo $paginator->sort(\'Make\', \'Car.make\');

How do I do a paginator sort and also specify it to go to the first page:

echo $paginator->sort('Make', 'Car.make');

If you're on page 6 and want to sort the list by car make. It sorts the list but puts you on page 6 of the sorted list. When someone clicks on the sort by "make" button, I want the paginator to take them to page 1 of the sort. I know there is an options['url']['page'] variable and that the sort function can be 'sort($title, $key = NULL, $options = array())'. However, I have no idea what the proper syntax is for setting that flag in the $paginator->sort statement abo开发者_开发问答ve. Please help, thanks!


Digging through the PaginatorHelper API a bit, this should work:

echo $paginator->sort('Make', 'Car.make', array('url' => array('page' => 1)));

Haven't tested it though.

0

精彩评论

暂无评论...
验证码 换一张
取 消