---
title: "zend framework 实现同页面中多个分页"
author: "skyfen"
date: "2010-10-21T09:00:01Z"
tags: []
categories: ["编程语言"]
slug: "zend-framework"
draft: false
lastmod: "2010-10-21T09:00:01Z"
id: 790116
url: "https://skyfen.iteye.com/blog/790116"
---

解决同一个页多个分页，相互间影响的问题。
zend framework 分页组件paginationControl带的有pagesctl.phtml分页模板。如果某一页面中两组程序分别要求一个分页。哪么可以先pagesctl.phtml模板复制成pagesctl2.phtml模板.
pagesctl2.phtml 页面
把所有
   url($this->param + array('page'
改成 
   url($this->param + array('page2'

这个page2是为接收参数用的，其它的page是paginationControl参数带过的不要动.


```java

public function abcAction(){
        。
        。
        。
     //第一个分页用的是第一个pagesctl.phtml分页模板 可以不动  
     $this->view->param = array();    
     $this->_paginator->setCurrentPageNumber($this->_getParam('page'));
        。
        。
        。
    //第二个分页用的是第二个pagesctl2.phtml分页模板
    //param改成了param2
     $this->view->param2 = array();    
     $this->_paginator->setCurrentPageNumber($this->_getParam('page2'));

}

```


abc.phtml页面



```java

        。
        。
        。
//第一个分页
 <tr class="row_bg_table" >
          <td colspan="8" align="right"  ><?php echo $this->paginationControl($this->transports, 'Sliding', 'pagesctl.phtml', array('param' => $this->param));?></td>
        </tr>

        。
        。
        。
//第二个分页
//param改成了param2
 <tr class="row_bg_table" >
          <td colspan="8" align="right"  ><?php echo $this->paginationControl($this->transports, 'Sliding', 'pagesctl2.phtml', array('param2' => $this->param));?></td>
        </tr>

```




如果你在同一页面还有更多分页，又不想他们相互间有影响,你可以使用这种方法在同一页面有N个分页而不会相互有影响的.
仅管这种方法不是很智慧，但是却很方便。