Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 如何定制will_分页?_Ruby On Rails_Will Paginate - Fatal编程技术网

Ruby on rails 如何定制will_分页?

Ruby on rails 如何定制will_分页?,ruby-on-rails,will-paginate,Ruby On Rails,Will Paginate,我在ruby 1.8.7和rails 2.3.8中使用will_分页,并获得如下分页链接: << 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 >> >和 > 帮助我如何显示分页链接,如下所示 << previou

我在ruby 1.8.7和rails 2.3.8中使用will_分页,并获得如下分页链接:

      << 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 >>
>和
>
帮助我如何显示分页链接,如下所示

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

想要自定义页面链接,这里我喜欢在第5页而不是第9页之后添加gap css。这可能吗

您可以编写自己的
链接渲染器
,并将其作为
渲染器
选项传递:

will_paginate(@items, :renderer => My:LinkRenderer)
查看并了解默认渲染器是如何工作的

更新:实际上,您不需要创建自己的渲染器来实现所需的效果。自定义WillPaginate,如:

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

它将按照您希望的方式呈现分页栏。您可以将初始化添加到
config/initializers
文件夹中的初始值设定项文件。

您好,谢谢,我已经在lib/folder下添加了分页列表链接呈现器.rb文件,并且我在视图页面PaginationListLinkRenderer中更改了:内部窗口=>2,:外部窗口=>2,:参数=>{“搜索”=>params[:search]})%>。但我还是没有得到任何改变。你能帮帮我吗?谢谢!当我在初始值设定项文件中给出:outer_window=>1和:inner_window=>1时,它会带来类似>的分页。