Try the Demo

Magento Forum

   
how to show pictures of all sub category from chosen by me main category
 
dunix
Jr. Member
 
Total Posts:  6
Joined:  2012-09-12
 

<?php
//gets all sub categories of parent category 'cat-id-7'
   
$cats Mage::getModel('catalog/category')->load(7)->getChildren();
   
$catIds explode(',',$cats);

   
$categories = array();
foreach(
$catIds as $catId{
    $category 
Mage::getModel('catalog/category')->load($catId); 
    
$categories[$category->getName()= array(
        
'url' => $category->getUrl(),
        
'img' => $category->getImageUrl()
    );
}
ksort
($categoriesSORT_STRING);
?>
<ul>
    
<?php if($category->getIsActive()): ?>
    <?php 
foreach($categories as $name => $data): ?>
        
<li>
            <
img src="<?php echo $data['img']; ?>" />
            <
a href="<?php echo $data['url']; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>"><?php echo $name?></a>
        </
li>   
    
<?php endforeach; ?>
    <?php 
endif; ?>
</ul>

<img src="<?php echo $data['img']; ?>" />

this is not working

my magento version is 1.7.0.2

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tamayo
Member
 
Total Posts:  33
Joined:  2009-01-09
 

Change your fist two lines to:

$_category = $this->getCurrentCategory();
$cats = $_category->getChildren();

 Signature 

Every Angle Media

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top