Zend Paginator - 页面链接
我有一个可用的分页器。我结合 Zend Paginator 和 jQuery 在页面之间切换。我的问题是页面链接的范围只有从 1 到 10,但它应该是例如从 1 到 13。我可以通过单击前进按钮到达第 13 页,但不显示页面链接 13。
分页器设置:
$paginator = new Zend_Paginator (
new Zend_Paginator_Adapter_DbSelect ( $programmeList ) );
$paginator->setItemCountPerPage ( 12 )
->setCurrentPageNumber ( $this->_getParam ( 'page', 1 ));
将分页器传递到视图:
if (! $this->_request->isXmlHttpRequest ()) {
$this->view->paginator = $paginator;
} else {
$this->view->currentPage = $paginator->getCurrentPageNumber ();
}
这就是我打印页面链接的方式:
foreach ( $this->pagesInRange as $page ) {
echo '<a href="#" id="page" page="'.$page.'">' . $page . '</a>';
}
有什么想法吗?
I have a working paginator. I combine Zend Paginator and jQuery to switch between pages. My problem is that the page links only have a range from 1 to 10 but it should be e.g. from 1 to 13. I can get to page 13 by clicking the forward button but the page link 13 is not displayed.
Paginator setup:
$paginator = new Zend_Paginator (
new Zend_Paginator_Adapter_DbSelect ( $programmeList ) );
$paginator->setItemCountPerPage ( 12 )
->setCurrentPageNumber ( $this->_getParam ( 'page', 1 ));
Pass paginator to the view:
if (! $this->_request->isXmlHttpRequest ()) {
$this->view->paginator = $paginator;
} else {
$this->view->currentPage = $paginator->getCurrentPageNumber ();
}
And this is how I print page links:
foreach ( $this->pagesInRange as $page ) {
echo '<a href="#" id="page" page="'.$page.'">' . $page . '</a>';
}
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Zend_Paginator 有一个 setPageRange 方法,它允许您指定要显示的页面数。它的默认值为 10,这解释了为什么 $this->pagesInRange 始终只显示 10 页。
Zend_Paginator has a setPageRange method which allows you to specify how many pages to show. It has a default of 10, which explains why $this->pagesInRange is always showing only 10 pages.
很高兴听到它有效,鲍勃。以下是其手动条目的链接: http://framework.zend .com/manual/en/zend.paginator.configuration.html
Great to hear it worked bob. Here's the link to the manual entry for it: http://framework.zend.com/manual/en/zend.paginator.configuration.html