首页 > 其他 > 详细

How to use pagination in Magento

时间:2014-04-12 22:07:39      阅读:483      评论:0      收藏:0      [点我收藏+]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 :

1
2
3
4
5
6
7
8
9
10
11
<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,布布扣,bubuko.com

How to use pagination in Magento

原文:http://www.cnblogs.com/fengliang/p/3660635.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!