2016-02-08 32 views
1

我正在照顧一個傳統的Zend項目。有一個表使用Paginator填充了一些值:Zend paginator - 是否可以設置自定義參數?

paginator = Zend_Paginator::factory($this->_getRecords($filter1, $filter2) ); 

$paginator->setCurrentPageNumber($this->_getParam('page')); 
$this->view->paginator = $paginator; 

現在就是這個問題。此分頁程序不知道過濾器(filter1和filter2)。

點擊某些頁面會導致空的filter1和filter2值。我想要做的是設置這些過濾器作爲分頁程序參數,可以smthing像:

/管理/用戶/指數/頁/ 7 /濾波器1 /值1 /過濾器2 /值2

然後可以這樣說:

paginator = Zend_Paginator::factory($this->_getRecords($this->_getParam('filter1'), $this->_getParam('filter2')) ); 

這可能嗎?

回答

3

Paginator不生成網址。網址由路由器生成。

發送過濾器模板當前頁面

$this->view->paginator = $paginator; 
$this->view->filters = array('filter1'=>$filter1, 'filter2'=>$filter2); 

在模板當前頁面發送過濾器,分頁程序模板

<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.tpl', array('filters'=>$this->filters)); ?> 

在分頁程序模板「pagination.tpl」將它們添加到URL生成功能

<a href="<?php echo $this->url($this->filters + array('page'=>($this->current-1))); ?>">prev</a> 

<a href="<?php echo $this->url($this->filters + array('page'=>($this->current+1))); ?>">next</a> 
相關問題