Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

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-11
 

<?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();

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