开发者

CakePHP pagination sort (by multiple criteria) issue

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'开发者_Go百科] = 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


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜