Display Categories with Image in Multiple Pages of Homepage - Magento

回眸只為那壹抹淺笑 提交于 2019-12-12 02:17:35

问题


In my Customization , i have more than 100 categories under Default Category so I want to Display all the categories in multiple pages with images Homepage - Magento.

Im Using the below code :

   <div class="category-products">
   <ul class="products-grid">
   <?php
$_categories=$this->getCurrentChildCategories();
if($_categories->count()):
$categorycount = 0;
foreach ($_categories as $_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();
if ($categorycount == 0){
$class = "first";
}
elseif ($categorycount == 3){
$class = "last";
}
else{
$class = "";
}
 ?>
<li class="item <?=$class?>">
  <a href="<?php echo $_category->getURL() ?>" title="<?php echo   $this->htmlEscape($_category->getName()) ?>"><img src="<?php echo $_category->getImageUrl() ?>" width="100" alt="<?php echo $this->htmlEscape($_category->getName()) ?>" /></a>
   <h2><a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a></h2>
  </li>
 <?php
endif;
if($categorycount == 3){
$categorycount = 0;
echo "</ul>\n\n<ul class=\"products-grid\">";
}
else{
$categorycount++;
}
   endforeach;
   endif;
   ?>
  </ul>
    </div>      

In this code im just getting only product with images but not in proper manner (not aligned) please anyone query me how to Display all the categories in multiple pages with images Homepage .


回答1:


To display in Multiple page you will need to use some pagination techniques ,

to display the product categories do refer

How to create Categories Grid (list) with images



来源:https://stackoverflow.com/questions/19048737/display-categories-with-image-in-multiple-pages-of-homepage-magento

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!