Say I have 30 pages being paginated with Kaminari:
#800 books, 25 per page
=paginate @books, :outer_window => 3, :window => 3
It looks like this:
1 2 3 4 … 30 31 32
There's no way to get to page 16 without clicking 5 times.
(* current page, [] = click)
It seems like a lot of work to get to the middle of the stack.
1 2 3 4 ... 15 16 17 ... 30 31 32
You can play with the inner and outer window options (link) but I don't think this will solve your problem.
As @Michal Szyndel's comment mentioned you will need to use the generator (rails g kaminari:views THEME
note: that you can pass -e to generate different templating languages). Once you have generated the files you can edit the "paginator" partial with some custom logic. For an intro to how to do this watch Ryan's railscast (starting at 4:53)
Hopefully this gets you far enough because how that middle window works when you aren't at the beginning or end of your pagination will depend on you window sizes and what you want. (e.g., If you have an outer window of 3 and an inner window of 2 with 50 pages what should the paginator links look like when you are on page 15?)
If you need more help just reply with a comment and I'll answer more specifically.
Extending the kaminari view elements is pretty simple. You need to customize the pagination helper, https://github.com/amatsuda/kaminari#customizing-the-pagination-helper
Specifically, and assuming you are using ERB, you'll want to edit your new app/views/kaminari/_gap.html.erb
file.
<%
url,data = url.split('?')
url += '?page=' + (num_pages/2)
%>
<span class="page gap">
<%= link_to_unless page.current?, page, url %>
</span>
This creates a link to your middle (really num_pages/2
-th) page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With