How to use pagination in Magento
classYour_Module_Block_Entityname_ListextendsMage_Core_Block_Template
{ protected function _construct(){
// We get our collection through our model
parent::_construct();
// Instantiate a new Pager block
$this->_entities =Mage::getModel('your_module/entityname')->getCollection()->setOrder('created_at', 'desc');
// /!\ The limit must be set before the collection
$pager =newMage_Page_Block_Html_Pager();// We set our limit (here an integer store in configuration).
// Add our Pager block to our current list block
$pager
->setLimit((int)Mage::getStoreConfig('your_module/entityname/pagination'))->setCollection($this->_entities);
$this->setChild('pager', $pager);
}
}
You just need now to include the call in your template (phtml) file :
<divclass="your_module_entities">
<?php foreach($this->_entities as $entity):?>
<divclass="entity">
<h2>
<?php echo $entity->getAttribute1();?>
</h2>
<p>
<?php echo $entity->getAttribute2();?>
</p>
</div>
<?php endforeach;?></div><?php echo $this->getChildHtml('pager');?>
How to use pagination in Magento的更多相关文章
- pagination 分页
<!DOCTYPE html> <html> <head> <title>pagination</title> <style type ...
- salesforce 零基础学习(四十九)自定义列表分页之使用Pagination实现分页效果 ※※※
上篇内容为Pagination基类的封装,此篇接上篇内容描述如何调用Pagination基类. 首先先创建一个sObject,起名Company info,此object字段信息如下: 为了国际化考虑 ...
- salesforce 零基础学习(四十八)自定义列表分页之Pagination基类封装 ※※※
我们知道,salesforce中系统标准列表页面提供了相应的分页功能,如果要使用其分页功能,可以访问http://www.cnblogs.com/zero-zyq/p/5343287.html查看相关 ...
- knockoutjs+ jquery pagination+asp.net web Api 实现无刷新列表页
Knockoutjs 是一个微软前雇员开发的前端MVVM JS框架, 具体信息参考官网 http://knockoutjs.com/ Web API数据准备: 偷个懒数据结构和数据copy自官网实例 ...
- LNMP环境magento常见错误
一.安装报404错误 git clone 下最新代码,跳转到index/install 安装时出现404错误 需要把伪静态规则加到nginx配置文件中: # # The default server ...
- Magento 新增字段的值读写丢失原因
某实体新增字段handreturn_status,欲操作之: $order_info = Mage::getModel('sales/order')->load($order_id); //se ...
- MAGENTO - APACHE SOLR INTEGRATION - PART II (SETUP)
MAGENTO - APACHE SOLR INTEGRATION - PART II (SETUP) Tue, 03/01/2011 - 18:30 Tweet Development E-Comm ...
- ajax pagination 布局刷新
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- Magento学习第一课——目录结构介绍
Magento学习第一课--目录结构介绍 一.Magento为何强大 Magento是在Zend框架基础上建立起来的,这点保证了代码的安全性及稳定性.选择Zend的原因有很多,但是最基本的是因为zen ...
随机推荐
- MFC 遍历FTP服务器目录中文乱码问题
在编写FTP客户端的时候我用的是server u来做我的测试服务器,而server u 默认使用utf-8作为默认字符集,vs则使用unicode作为默认字符集,所以会产生乱码,将server u的默 ...
- 可以供MFC调用的,QT实现的DLL(qtwinmigrate实现)
MFC和QT的消息循环机制不同,所以,要让QT写的DLL可以供MFC调用,要做一点特殊的处理 #include <qmfcapp.h> #include <qwinwidget.h& ...
- Oracle 索引扫描的4种类型
根据索引的类型与where限制条件的不同,有4种类型的Oracle索引扫描: 3,4可归一种 (1) 索引唯一扫描(index uniquescan) (2) 索引范围扫描(index range s ...
- OpenSSL win 下报错 OPENSSL_Uplink(58D46000,08): no OPENSSL_Applink
python 中使用 M2Crypto 想读写文件时总是报: OPENSSL_Uplink(58D46000,08): no OPENSSL_Applink windows 平台下使用 openssl ...
- 首次登录与在线求助man page
为了避免瞬间断电造成的Linux系统损害,建议作为服务器的Linux主机应该加上不断电系统来持续提供稳定的电力. 在终端环境中,可依据提示符为$或#判断为一般几号或root账号. 要取得终端支持的语言 ...
- CentOS 安装nload(流量统计)
yum install gcc gcc-c++ ncurses-devel wget http://www.roland-riegel.de/nload/nload-0.7.2.tar.gz tar ...
- docker相关配置
一.概述: 1.centos7下,默认firewalld为防火墙, systemctl status firewalld.service 2.关闭firewalld, systemctl stop f ...
- timeout Timeout时间已到.在操作完成之前超时时间已过或服务器未响应
Timeout时间已到.在操作完成之前超时时间已过或服务器未响应 问题 在使用asp.net开发的应用程序查询数据的时候,遇到页面请求时间过长且返回"Timeout时间已到.在操作完成之间超 ...
- 经典 SQL
经典sql 总结一些经常用到或碰到的SQL语句,希望能与大家分享,同时也希望大家能提供更多的精妙SQL语句..... 1.delete table1 from (select * from tab ...
- sql的集合运算
表的加减法 union:使用union 对表进行假发(并集)运算, union等集合运算符通常都会去除重复记录. select shohin_id, shohin_mei from shohin un ...