Add pagination to custom module in Magento?

adam

New Member
I am trying to add pagination in custom module. I have the following code under Block folder in articles.php\[code\]class Compname_Modname_Block_Articles extends Mage_Core_Block_Template{ public function __construct() { parent::__construct(); $collection = Mage::getModel('articles/articles')->getCollection(); $this->setCollection($collection); }........ public function getTagsList(){ $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager'); $pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all')); $pager->setCollection($this->getCollection()); $this->setChild('pager', $pager); $this->getCollection()->load(); return $this; } public function getPagerHtml() { return $this->getChildHtml('pager'); }...................}\[/code\]I have cms page in admin end having the following code \[code\] <reference name="content"> <block type="articles/articles" name="articles.tags" as="tags.articles" template="articles/tags.phtml" /> </reference>\[/code\]Under Articles folder in my theme , i have the file called \[code\]tags.phtml\[/code\] having the code like,\[code\] <?php echo $this->getPagerHtml(); ?> // this displays exact pagination with page numbers <?php $collection = $this->getTagsList(); var_dump($collection->getSize()); // Always return NULL ?>\[/code\]getSize() always return \[code\]NULL\[/code\] so i am not getting my collection value. Kindly advice on this
 
Top