views:

131

answers:

1

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 above. Please help, thanks!

+1  A: 

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.

deceze
I tried this beforehand and it didn't work. It would still stay on page 6.
Hooman Ahmadi
Hmm, just tried it and it works for me. Cake 1.2.5. Care to post your code that doesn't work?
deceze
Ok it works now. Not sure why. Perhaps I didn't cut and paste correctly. However, there is still another issue. On the same page I have a form submit. Basically you can fix refine your search and submit. I'm havin the same issue. When you do a $form->end(); The page loads with new search criteria, but the paginator keeps it on page 6 (for example). How do I get the form submit to tell the paginator to go to page 1?
Hooman Ahmadi