Created
August 15, 2012 11:59
-
-
Save ceckoslab/3359512 to your computer and use it in GitHub Desktop.
Well formatted script for showing subcategories images in Magento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $_maincategorylisting=$this->getCurrentCategory()?> | |
<?php $_categories=$this->getCurrentChildCategories()?> | |
<?php if($_categories->count()):?> | |
<?php foreach ($_categories as $_category):?> | |
<?php 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(); | |
// Test if the current category has an image assigned to it or not | |
if($_imageUrl=!$this->getCurrentCategory()->getImageUrl()): ?> | |
<?php /* Default subcategory jpg if no image exists */ ?> | |
<div class="category-box"> | |
<a href="<?php echo $this->getCategoryUrl($_category)?>"> | |
<img src="<?php echo $this->getSkinUrl('images/catalog/product/placeholder/thumbnail.jpg') ?>"> | |
</a> | |
<p><a href="<?php echo $this->getCategoryUrl($_category)?>"> <?php echo $catName ?></a></p> | |
</div> | |
<?php endif ?> | |
<?php if($_imageUrl=$this->getCurrentCategory()->getImageUrl()):?> | |
<?php /* Displays the subcategory image */ ?> | |
<div class="category-box"> | |
<a href="<?php echo $this->getCategoryUrl($_category)?>"> | |
<img src="<?php echo $_imageUrl?>" height="80"> | |
</a> | |
<p><a href="<?php echo $this->getCategoryUrl($_category)?>"> <?php echo $_category->getName()?></a></p> | |
</div> | |
<?php endif; | |
endif;?> | |
<?php endforeach ?> | |
<?php $layer->setCurrentCategory($_maincategorylisting); ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment