yoshyosh
yoshyosh

Reputation: 14086

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?

Upvotes: 3

Views: 2339

Answers (1)

Ryan Brunner
Ryan Brunner

Reputation: 14851

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

Upvotes: 12

Related Questions