php – SilverStripe PaginatedPages显示自定义摘要
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – SilverStripe PaginatedPages显示自定义摘要,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1982字,纯文字阅读大概需要3分钟。
内容图文
我在使用PaginatedPages时遇到了麻烦.在docs中,可以自定义摘要.
有我的代码:
public function PaginatedPages($n = 10) {
$list = Page::get()->sort(array('Date' => DESC));
$Pages = new PaginatedList($list, $this->request);
if ($_GET['results'] != "") {
$n = $_GET['results'];
}
$Pages->setPageLength($n);
return $Pages;
}
模板页面底部的分页:
<div id="PaginatedPages">
<% if $PaginatedPages.MoreThanOnePage %>
<% if $PaginatedPages.NotFirstPage %>
<a class="prev" href="$PaginatedPages.PrevLink"><</a>
<% end_if %>
<% loop $PaginatedPages.Pages %>
<% if $CurrentBool %>
<a class="current">$PageNum</a>
<% else %>
<% if $Link %>
<a href="$Link">$PageNum</a>
<% else %>
...
<% end_if %>
<% end_if %>
<% end_loop %>
<% if $PaginatedPages.NotLastPage %>
<a class="next" href="$PaginatedPages.NextLink">></a>
<% end_if %>
<% end_if %>
</div>
此代码重现:
[1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20]
我不想要这个.如果一个有20页的结果,它将显示所有,结果是漫长而丑陋的.
我想要以下内容:
[1] ... [9] [10] [11] [12] [13] ... [20]
解决方法:
您可以使用$PaginatedPages.PaginationSummary来实现此目的:
<div id="PaginatedPages">
<% if $PaginatedPages.MoreThanOnePage %>
<% if $PaginatedPages.NotFirstPage %>
<a class="prev" href="$PaginatedPages.PrevLink"><</a>
<% end_if %>
<% loop $PaginatedPages.PaginationSummary %>
<% if $CurrentBool %>
<a class="current">$PageNum</a>
<% else %>
<% if $Link %>
<a href="$Link">$PageNum</a>
<% else %>
...
<% end_if %>
<% end_if %>
<% end_loop %>
<% if $PaginatedPages.NotLastPage %>
<a class="next" href="$PaginatedPages.NextLink">></a>
<% end_if %>
<% end_if %>
</div>
PaginationSummary返回一个摘要分页,它限制了当前页面周围显示的页面数,以实现视觉平衡.它
PaginationSummary可以使用参数来控制当前页面周围显示的页数.默认情况下,PaginationSummary将在当前页面周围显示4页(之前2页,之后2页.例如[1] … [4] [5] [[6]] [7] [8] … [25] ).调用PaginationSummary(6)将导致当前页面之前3页和3页之后.例如[1] …… [3] [4] [5] [[6]] [7] [8] [9] …… [25].数字应该始终是均匀的,因为每页的数量的一半显示在当前页面的两侧.
内容总结
以上是互联网集市为您收集整理的php – SilverStripe PaginatedPages显示自定义摘要全部内容,希望文章能够帮你解决php – SilverStripe PaginatedPages显示自定义摘要所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。