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 ...
随机推荐
- opencv菜鸟学习之旅cvNorm
Norm 计算数组的绝对范数, 绝对差分范数或者相对差分范数 double cvNorm( const CvArr* arr1, const CvArr* arr2=NULL, int norm_ty ...
- CLR读书笔记——委托
协变性和逆变性 协变性是指方法能返回从委托返回类型派生的一个类型. 逆变性是指获取的参数可以是委托参数类型的基类. 举个例子吧,看以下定义的委托,以及方法. delegate Object MyCal ...
- Seafile 推出 “分布式文件同步技术” 打造的私有云服务
近两年来 Dropbox 等云储存服务迅速窜红,各大巨头纷纷推出自家的云储存服务(苹果的 iCloud, 微软的 SkyDrive, Google 即将推出的 GDrive),国内也有类似的服务(金山 ...
- 如何诊断crs 安装时 root.sh 脚本执行错误
troubleshooting root.sh problem ------*for 10g and 11.1 1.查证公网,私网的节点名是可以互相ping通的 2.---查证OCR/Voting 文 ...
- linux之SQL语句简明教程---CREATE INDEX
索引 (Index) 可以帮助我们从表格中快速地找到需要的资料.举例来说,假设我们要在一本园艺书中找如何种植青椒的讯息.若这本书没有索引的话,那我们是必须要从头开始读,直到我们找到有关种直青椒的地方为 ...
- 搭讪培训班 - 名品试用 - YOKA时尚论坛 - YOKA社区
搭讪培训班 - 名品试用 - YOKA时尚论坛 - YOKA社区 搭讪培训班 发贴回复 发新话题 发布投票 搭讪培训班 1330 1 阅读 回复 跳转到指定楼层 加为好友 时尚懒洋洋 工作:无业游 ...
- 《编写高质量代码 改善Java程序的151个建议》书摘
例子1:三元操作符的陷阱 int i = 80; String str1 = String.valueOf(i < 100 ? 90 : 100); String str2 = String.v ...
- mongodb导出命令
./mongoexport -d admin -c col -o col.json 找到了 导出所有数据库的 http://www.jb51.net/article/52498.htm
- 奇妙的算法之LCS妙解
LCS算法妙解 LCS问题简述:最长公共子序列 一个数列 S,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则S 称为已知序列的最长公共子序列. LCS问题的分支:最长公共子串 ...
- Walking Ant(一道有意思的蚂蚁游戏,bfs)
Walking Ant Time Limit: 2 Seconds Memory Limit: 65536 KB Ants are quite diligent. They sometime ...