I make a pagination for html tables on this guide :
This is my app/code/local/Developer/Vendor/Block/Customer.php
<?php class VitaliyDev_Vendor_Block_Customer extends Mage_Core_Block_Template { public function _construct() { parent::_construct(); $collectionProducts = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToSelect(array( 'name', 'price', 'owner_id', )) ->addAttributeToFilter('owner_id', array( 'id' => Mage::getSingleton('customer/session')->getCustomer()->getId(), )); $this->setCollection($collectionProducts); } protected function _prepareLayout() { parent::_prepareLayout(); $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager'); $pager->setCollection($this->getCollection()); $this->setChild('pager', $pager); $this->getCollection()->load(); return $this; } public function getPagerHtml() { return $this->getChildChildHtml('pager'); } } My layout app/design/frontend/rwd/default/layout/developer_vendor.xml
<developervendor_customer_index> <update handle="customer_account"/> <reference name="content"> <block type="developervendor/customer" name="index.content" template="developervendor_vendor/customer/index.phtml" /> </reference> </developervendor_customer_index> Template app/design/frontend/rwd/default/template/developer_vendor/customer/index.phtml
<div class="title_customer_products"> <?php echo $this->__('Your products')?> </div> <?php $collection = $this->getCollection(); ?> <?php echo $this->getPagerHtml() ?> <table class="customer-products data-table"> <thead> <th><?php echo $this->__('Id Product')?></th> <th><?php echo $this->__('Name Product')?></th> <th><?php echo $this->__('Price Product')?></th> </thead> <tbody> <?php foreach ( $this->getCollection() as $product):?> <tr> <td><?php echo $product->getId()?></td> <td><?php echo $product->getName()?></td> <td><?php echo $product->getPrice()?></td> </tr> <?php endforeach;?> </tbody> </table> <?php echo $this->getPagerHtml() ?> <form action="<?php echo Mage::getUrl('*/customer/add')?>"> <button class="add_product_button button" type="submit">add product</button> </form> No result (Pagination does not appear!
What am I doing wrong ?