zend framework 分页

2012年4月2日 发表评论 阅读评论

<?php
function indexAction()
    {
        $this->view->title = "图书管理系统后台页面";
        $books = new Books();
        //$this->view->books = $books->fetchAll();

        $page=1;//默认页
        $numPerPage=1;//每页显示的条数
        if(isset($_GET['page']) && is_numeric($_GET['page'])){
            $page=$_GET['page'];//取到URL传过来的页数码
        }
        $array=$books->fetchAll();
        $pageinator=Zend_Paginator::factory($array);
        $pageinator->setCurrentPageNumber($page)
                    ->setItemCountPerPage($numPerPage);
        $this->view->paginator=$pageinator;
    }

?>
<?php if ($this->pageCount): ?>
<div class="paginationControl">
<!– Previous page link –>
<?php if (isset($this->previous)): ?>
<a href="<?= $this->url(array(‘page’ => $this->previous)); ?>">&lt; 上一页</a> |
<?php else: ?>
<span class="disabled">&lt; 上一页</span> |
<?php endif; ?>
<!– Numbered page links –>
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
    <a href="<?= $this->url(array(‘page’ => $page)); ?>"><?= $page; ?></a> |
<?php else: ?>
    <?= $page; ?> |
<?php endif; ?>
<?php endforeach; ?>

<!– Next page link –>
<?php if (isset($this->next)): ?>
<a href="<?= $this->url(array(‘page’ => $this->next)); ?>">下一页 &gt;</a>
<?php else: ?>
<span class="disabled">下一页 &gt;</span>
<?php endif; ?>
</div>
<?php endif; ?>


转载请注明来自:[MSN Spaces]http://msn.shandian.biz/227.html

  1. 本文目前尚无任何评论.