I have to display category,subcategory and image on home page.I am using custom theme.

Foe example: My home page category,subcategory and image display is like below

Cat1 Cat2 Cat3
Subcat1 Image Subcat1 Image Subcat1 Image SubCat2 Subcat2 Subcat2 Subcat3 SUbcat3 Subcat3

Please help me how to do it.Its urgent please give me idea how to do it.

Many Thanks, Padma

  • I am using custom theme.
    – Padma G.C.
    Mar 13, 2015 at 4:52

1 Answer 1


You could do something like this. Add a custom catalog/homecategories.phtml file and add it in your local.xml.


$helper = Mage::helper('catalog/category');
/** @var $helper Mage_Catalog_Helper_Category */

$topCategories = $helper->getStoreCategories(true);

<?php if (!empty($topCategories)): ?>
    <div class="home-categories">

        <ul class="level-1">
            <?php foreach ($topCategories as $topCategory): ?>
                <?php /** @var $topCategory \Mage_Catalog_Model_Category */ ?>
                    <a href="<?php echo $helper->getCategoryUrl($topCategory); ?>"><?php echo $topCategory->getName(); ?></a>

                    <?php if ($topCategory->hasChildren()): ?>
                        <ul class="level-2">
                            <?php foreach ($topCategory->getCategories($topCategory, 0, true) as $category): ?>
                                <?php /** @var $category \Mage_Catalog_Model_Category */ ?>
                                    <a href="<?php echo $helper->getCategoryUrl($category); ?>"><?php echo $category->getName(); ?></a>
                                    <a href="<?php echo $helper->getCategoryUrl($category); ?>">
                                        <img src="<?php echo $category->getImageUrl();?>" alt="" />
                            <?php endforeach; ?>
                    <?php endif; ?>
            <?php endforeach; ?>

<?php endif; ?>



    <reference name="content">
        <block type="core/template" name="home-categories" as="home_categories" before="-">
            <action method="setTemplate"><template>catalog/homecategories.phtml</template></action>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.