views:

33

answers:

2

I am currently trying to perform pagination using CakePHP's pagination helper.

I have a series of "Listing" rows that are returned and paginated as expected. When the user clicks on the column headings however, I'd like the sort() method to be forced to prioritise certain listings (i.e. priority listings, those with ['Listing']['priority_flag'] = 1) first. However, when the user clicks on the column header, the browser url is set to

www.mysite.com/listing/index/page:1/sort:description/direction:asc

Hence, it is only sorting by description (as the user clicked on the column header for 'description'), ignoring anything to do with priority_flag.

All help appreciated!

gaioshin

+1  A: 

I did this by writing an override paginate() function on the appropriate model. For the parameters, look carefully at the structure of the url you have pasted (you can modify it to suit your own ends, but then you would need to deviate from the pagination helper).

It's not difficult to do, but will require some thought. Look at the core to see how it works.

Leo
Thanks for the input - may try this if I freak out at modifying the core code :)
Gaioshin
+1  A: 

Take a look here.

bancer
Thanks for the link - I am currently using 1.3 and haven't come across any evidence that it has been incorporated, so I will attempt to use Avinash G's method.
Gaioshin