蕲春人 - 软件开发

简单就是美.

Show More Detail Info on Will_paginate Bar

Just create an extension in lib directory:

in Rails.root/lib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class PaginationDetailLinkRenderer < WillPaginate::LinkRenderer

  # useage: <%=will_paginate @auctions, :renderer => PaginationDetailLinkRenderer %>

  def to_html
    links = @options[:page_links] ? windowed_links : []
    links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
    links.push    page_link_or_span(@collection.next_page,     'disabled next_page', @options[:next_label])
    html = links.join(@options[:separator])
    html = "每页显示<b>#{@collection.per_page}</b>条数据,共有<b>#{total_pages}</b>页,  共有<b>#{@collection.total_entries}</b>条数据" + html
    @options[:container] ? @template.content_tag(:div, html, html_attributes) : html
  end

end

And the result is like this: will_paginate bar