php - How to add pagination in subcategory collection in magento? -


i have written following code display subcategories

    <ul class="">   <?php $_categories=$this->getcurrentchildcategories(); if($_categories->count()): $categorycount = 0; foreach ($_categories $_category): if($_category->getisactive()): $cur_category=mage::getmodel('catalog/category')->load($_category->getid()); $layer = mage::getsingleton('catalog/layer'); $layer->setcurrentcategory($cur_category); $catname = $this->getcurrentcategory()->getname(); ?>   <li class="">     <div class="">       <div class="">         <div class=""> <a href="<?php echo $_category->geturl() ?>" title="<?php echo $this->htmlescape($_category->getname()) ?>" class="">           <?php                     $imageurl = mage::getbasedir('media')."/"."catalog"."/"."category"."/".$this->getcurrentcategory()->getthumbnail();                      $imageresized = mage::getbasedir('media')."/"."catalog"."/"."category"."/"."resize/".$this->getcurrentcategory()->getthumbnail();                       if (!file_exists($imageresized) && file_exists($imageurl))                      {                      $imageobj = new varien_image($imageurl);                     $imageobj->constrainonly(true);                     $imageobj->keepaspectratio(true);                     $imageobj->keepframe(false);                     $imageobj->quality(100);                     $imageobj->resize(270, 270);                     $imageobj->save($imageresized);                     }                     ?>           <span class=""><img src="<?php echo mage::getbaseurl('media').'catalog/category/resize/'.$this->getcurrentcategory()->getthumbnail(); ?>" alt="<?php echo $this->htmlescape($_category->getname()) ?>"/></span> </a> </div>       </div>       <div class="">         <div class="">           <div class=""> <a href="<?php echo $_category->geturl() ?>" title="<?php echo $this->htmlescape($_category->getname()) ?>"><?php echo $this->htmlescape($_category->getname()) ?></a> </div>         </div>       </div>     </div>   </li>   <?php endif;  endforeach; endif; ?> </ul> 

i want add pagination in page, have tried solutions following not worked either

parent::_preparelayout(); $pager = $this->getlayout()->createblock('page/html_pager', 'custom.pager');     $pager->setavailablelimit(array(15=>15));     $pager->setcollection($_categories);      $this->setchild('pager', $pager); 

can have idea on how add pagination in subcategory listing page?

please guide me new magento development.

thanks in advance.

inside mage_catalog_block_navigation have custom method :

public function getcurrentchildcategories() {     if (null === $this->_currentchildcategories) {         $layer = mage::getsingleton('catalog/layer');         $category   = $layer->getcurrentcategory();         $this->_currentchildcategories = mage::getmodel('catalog/category')->getcollection();          $pager = new mage_page_block_html_pager();         $pager->setlimit(100)->setcollection($this->_currentchildcategories);         $this->setchild('pager', $pager);          /* @var $collection mage_catalog_model_resource_eav_mysql4_category_collection */         $this->_currentchildcategories->addattributetoselect('url_key')             ->addattributetoselect('name')             ->addattributetoselect('is_anchor')             ->addattributetoselect('image')              ->addattributetofilter('is_active', 1)             ->addidfilter($category->getchildren())             ->setorder('name', 'asc')             ->joinurlrewrite()             ->load();          $productcollection = mage::getresourcemodel('catalog/product_collection');         $layer->prepareproductcollection($productcollection);         $productcollection->addcounttocategories($this->_currentchildcategories);     }     return $this->_currentchildcategories; } 

i think it's not best works.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -