Zend_Paginatorでページング

1.Zend_Paginator_Adapter_Arrayで配列をZend_Paginatorに渡す。
他にもselect文を渡したりできたような。

$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($aryRs));

2.1ページごとの表示数を設定
$paginator->setItemCountPerPage(10);

3.現在のページ番号をパラメーターからgetし、設定
$paginator->setCurrentPageNumber($this->_getParam(‘page’));

4.スクロール方法の設定
Zend_Paginator::setDefaultScrollingStyle(‘Sliding’);

5.<prev 1 2 3 next> のようなものを表示するphtmlファイルを作成し、設定する。
Zend_View_Helper_PaginationControl::setDefaultViewPartial(‘layout/pager.phtml’);

$this->pageCount ページ数
$this->pagesInRange ページレンジ
$this->url(array(‘page’ => $page)) URL
$this->current 現在のページ
$this->previous 前のページ
$this->next 次のページ

6.viewにpaginatorを設定する。
$this->view->paginator = $paginator;

7.viewで表示する
<?php echo $this->paginator ?>

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です