Zend_Paginator分页

在controller中写入:

private $_aghqmztj;
 
 public function init()
 {
 }
 
 public function indexAction()
 {
  $numPerPage = 10;
  $page = $this->_request->getParam('page',1);
  $offset = $numPerPage*$page;
  $_aghqmztj=new Model_DbTable_Aghqmztj();
        $stockCodeList = $_aghqmztj->getStockCodeList();
       
        $paginator = Zend_Paginator::factory($stockCodeList);
        $paginator->setCurrentPageNumber($page)
                  ->setItemCountPerPage($numPerPage)
                  ->setPageRange(8);
        $this->view->paginator = $paginator;
 }

 

在该Action的视图文件中写入:

 

<?php if( count($this->paginator) ):?>
    <?php foreach ($this->paginator as $item): ?>
        <ul>
            <li><?php echo $item['Aghqjtsj02'];?></li>
        </ul>
    <?php endforeach;?>
<?php endif;?>

<?php echo $this->paginationControl($this->paginator,'Elastic','pagelist.phtml');?>

 

在view目录下的创建pagelist.phtml文件:


<?php if($this->pageCount):?>
    <div class="paginationControl">
        <?php if( isset($this->first) ):?>
            <a href="<?php echo $this->url(array('controller'=>'search','action'=>'index','page'=>$this->first));?>">&lt;首页</a>
            <?php else: ?>
            <span class="disabled">&lt;首页</span>
        <?php endif;?>
       
        <?php if( isset($this->previous) ):?>
            <a href="<?php echo $this->url(array('controller'=>'search','action'=>'index','page'=>$this->previous));?>">&lt;上一页</a>
            <?php else: ?>
            <span class="disabled">&lt;上一页</span>
        <?php endif;?>
        <?php foreach ($this->pagesInRange as $page):?>
            <?php if($page !=$this->current):?>
                <a href="<?php echo $this->url(array('controller'=>'search','action'=>'index','page'=>$page));?>"><?php echo $page;?></a>|
            <?php else :?>
                <?php echo $page;?>|
            <?php endif;?>
        <?php endforeach;?>
       
        <?php if(isset($this->next)):?>
            <a href="<?php echo $this->url(array('controller'=>'search','action'=>'index','page'=>$this->next));?>">下一页&gt;</a>
        <?php else:?>
            <span class="disabled" >下一页&gt;</span>
        <?php endif;?>
       
         <?php if( isset($this->last) ):?>
            <a href="<?php echo $this->url(array('controller'=>'search','action'=>'index','page'=>$this->last));?>">尾页&gt;</a>
            <?php else: ?>
            <span class="disabled">尾页&gt;</span>
        <?php endif;?>
       
        <span>第<?php echo $this->current;?>页</span>
        <span>共<?php echo $this->pageCount;?>页</span>
        <span>共<?php echo $this->totalItemCount;?>条</span>
    </div>
<?php endif;?>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值