Zend 框架中的分页 [英] Pagination in Zend Framework

查看:61
本文介绍了Zend 框架中的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Zend 的菜鸟,如果您能帮助我弄清楚如何在我的情况下使用分页,我将不胜感激.

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.

这是我的视图这是我的控制器

我正在使用 API 访问我的模型.

I am using APIs to access my models.

我在 Zend 中研究并阅读了很多关于分页的内容,但我在实现它时遇到了困难.感谢您愿意帮助我.

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.

推荐答案

在你的控制器的第 36 行写:(假设 $resultq 是一个有效的 zend_paginator 参数)

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;

现在在你的视图中你必须添加分页控件,要么直接在视图中做,要么使用模板(例如,你可以将模板存储在 application/views/scripts/templates 中),这是一个分页模板的例子: http://zendgeek.blogspot.com/2009/07/zend-pagination-example.html

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'); ?>

而不是使用 <?php foreach ($this->basicBwDetails as $result): ?> 使用 <?php foreach ($this->paginator作为 $result): ?>

这篇关于Zend 框架中的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆