Redirecting paginator->sort to the first page in Cakephp
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.
精彩评论