开发者

How to limit the amount of pages displayed in the links of will_paginate

I want to make my current will_paginate that looks like this:

<-Previous 1 2 3 4 5 Next->

Look like this

<-Previous 1 2 Next-> 

How do I 开发者_开发知识库control the amount of pages that can be displayed between previous and next?


The inner_window and outer_window properties can be used to manipulate how many page links you see on each page. You can pass them to the will_paginate method on your view (if you only want to limit the number of links for one page).

If you want to limit the number of pages shown throughout your application, the best approach is an initializer file (call it something like will_paginate.rb). You can set global configuration options like so:

WillPaginate::ViewHelpers.pagination_options[:inner_window] = 3
WillPaginate::ViewHelpers.pagination_options[:outer_window] = 2
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜