使用 Zend_Paginator 时,我不希望它显示所有的分页链接。这是我实施它的方式:
$adapter = new Zend_Paginator_Adapter_DbSelect($result);
$paginator = new Zend_Paginator($adapter);
$page=$this->_getParam('page',1);
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($page);
$this->view->paginator=$paginator;
现在它向我展示了所有的链接。例如,每页有 100 条记录和 10 行,所以它会显示 1 到 10 个链接。我怎样才能有 5 个链接,从 1 到 5? 像这样:
"start" "previous" 1 2 3 4 5 "Next" "End"
已编辑
<!--Number page links-->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="<?= $this->url(array('page' => $page)); ?>">
<span class="fg-button ui-button ui-state-default"><?= $page; ?></span>
</a>
<?php else: ?>
<span class="fg-button ui-button ui-state-default ui-state-disabled" ><?= $page; ?></span>
<?php endif; ?>
<?php endforeach; ?>
如何更改它以使其仅显示 5 个链接?
$adapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginator = new Zend_Paginator($adapter);
$page=$this->_getParam('page',1);
$paginator->setItemCountPerPage(10);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(5);
$this->view->paginator=$paginator;