Advertisement
Guest User

Fixed magento sub category view

a guest
Oct 8th, 2011
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. /**
  2.   * Original code by Jake Rutter
  3.   * @website: http://www.onerutter.com/web/magento-custom-category-images-listing-block-tutorial.html#idc-ctools
  4.   * Fixed by func0der
  5.   *
  6.   **/
  7.  
  8.  
  9. <div id="categories">
  10.     <div class="col_full">
  11.         <div class="listing" >
  12.         <?php
  13.             $_maincategorylisting = $this->getCurrentCategory();
  14.             $_categories = $this->getCurrentChildCategories()
  15.  
  16.             if($_categories->count()):
  17.                 foreach ($_categories as $_category):
  18.                     if($_category->getIsActive()):
  19.                         $cur_category=Mage::getModel('catalog/category')->load($_category->getId());
  20.                         $layer = Mage::getSingleton('catalog/layer');
  21.                         $layer->setCurrentCategory($cur_category);
  22.  
  23.                         $catName = $this->getCurrentCategory()->getName();
  24.                        
  25.                         if($_imageUrl = $this->getCurrentCategory()->getImageUrl()):
  26.             ?>
  27.  
  28.             <div class="category-box">
  29.                 <div class="category-image-box">
  30.                     <a href="<?php echo $this->getCategoryUrl($_category)?>"><img src="<?php echo $_imageUrl?>" height="80"></a>
  31.                 </div>
  32.                 <div class="category-name">
  33.                     <p>
  34.                         <a href="<?php echo $this->getCategoryUrl($_category)?>"> <?php echo $_category->getName()?></a>
  35.                     </p>
  36.                 </div>
  37.             </div>
  38.             <?php
  39.                         else:
  40.             ?>
  41.             <div class="category-box">
  42.                 <div class="category-image-box">
  43.                     <a href="<?php echo $this->getCategoryUrl($_category)?>"><img src="<?php echo $this->getSkinUrl('images/category_image_default.gif'); ?>"></a>
  44.                 </div>
  45.                 <div class="category-name">
  46.                     <p>
  47.                         <a href="<?php echo $this->getCategoryUrl($_category)?>"><?php echo $catName ?></a>
  48.                     </p>
  49.                 </div>
  50.             </div>
  51.             <?php
  52.                         endif; /* END: if($_imageUrl=!$this->getCurrentCategory()->getImageUrl()) */
  53.                     endif; /* END: $_category->getIsActive()) */
  54.                 endforeach; /* END: ($_categories as $_category) */
  55.                 /* This resets the category back to the original pages category
  56.                 ****     If this is not done, subsequent calls on the same page will use the last category
  57.                 ****    in the foreach loop
  58.                 */
  59.                 $layer->setCurrentCategory($_maincategorylisting);
  60.                 endif; /* END: if($_categories->count()) */
  61.             ?>
  62.         </div>
  63.         <br clear=all>
  64.     </div>
  65. </div>
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement