will_paginate的默认属性有:
@@pagination_options = {
:class => 'pagination',
:previous_label => '« Previous',
:next_label => 'Next »',
:inner_window => 4, # links around the current page
:outer_window => 1, # links around beginning and end
:separator => ' ', # single space is friendly to spiders and non-graphic browsers
:param_name => :page,
:params => nil,
:renderer => 'WillPaginate::LinkRenderer',
:page_links => true,
:container => true
}
改变方法有三:
1、找到
【C:\Ruby\lib\ruby\gems\1.8\gems\will_paginate-2.3.14\lib\will_paginate\view_helpers.rb】
改上面例出的默认属性。
优点:一劳永逸,任何此机器上的项目全改掉了
缺点:换个运行环境,就失效了。
2、在【yourapp\config\environment.rb】中加入:
WillPaginate::ViewHelpers.pagination_options[:class] = "yourclass"
WillPaginate::ViewHelpers.pagination_options[:previous_label] = "前一页"
WillPaginate::ViewHelpers.pagination_options[:next_label] = "后一页"
...
...
3、如果你闲得蛋疼,你也可以自定义tag:
def will_paginate_tag(kgroup, klass)
html = []
html << will_paginate(kgroup, :previous_label => '上一页', :next_label => '下一页', :class => klass)
content_tag("div", html.join(" "))
end