prabu
prabu

Reputation: 6171

How to customize will_pagination?

I am using will_pagination with ruby 1.8.7 and rails 2.3.8 and getting pagination link like,

      << previous  1 2 3 4 5 6 7 8 9 ... 66 67 next >> and 
      << previous 1 2 ... 30 31 32 33 34 35 36 37 38 39 ... 66 67 next >>

Help me how to present pagination link like below,

      << previous 1 2 3 4 5 ... 66 67 next >> (or)
      << previous 1 2 ... 30 31 ... 66 67 next >>

Want to customize page links, here i like bring gap css after page 5 instead of page 9. Is this possible?

Upvotes: 0

Views: 632

Answers (1)

Behrang Saeedzadeh
Behrang Saeedzadeh

Reputation: 47913

You can write your own LinkRenderer and pass it as the renderer option:

will_paginate(@items, :renderer => My:LinkRenderer)

Have a look at LinkRendererBase and LinkRenderer to see how the default renderer works.

Update: Actually you don't need to create your own renderer to achieve what you want. Customize WillPaginate like:

WillPaginate::ViewHelpers.pagination_options[:inner_window] = 2
WillPaginate::ViewHelpers.pagination_options[:outer_window] = 1

And it will render the pagination bar like the way you want it to. You can add the initialization to an initializer file in the config/initializers folder.

Upvotes: 2

Related Questions