Pagination in Zend Framework

别说谁变了你拦得住时间么 提交于 2019-12-08 00:27:33

问题


I am a noob in Zend and I would appreciate if you could help me to figure out how to use pagination in my case.

this is my view and this is my controller

I am using APIs to access my models.

I researched and read a lot about pagination in Zend but I had/have trouble implementing it. Thank you for your willingness to help me out.


回答1:


in your controller in line 36 write : (assuming $resultq is a valid zend_paginator param)

$paginator = Zend_Paginator::factory($resultq);      
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); // page number
$paginator->setItemCountPerPage(20); // number of items to show per page

$this->view->paginator= $paginator;

now in your view you have to add pagination controls, either do it directly in the view or use a template (you can store templates in application/views/scripts/templates for example), here is an example of a pagination template : http://zendgeek.blogspot.com/2009/07/zend-pagination-example.html

then in your view you have to integrate the template (wherever you want the controls to appear) using:

 <?php echo $this->paginationControl($this->paginator, 'Sliding', 'templates/pagination.phtml'); ?>

and instead of using <?php foreach ($this->basicBwDetails as $result): ?> use <?php foreach ($this->paginator as $result): ?>



来源:https://stackoverflow.com/questions/8800294/pagination-in-zend-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!