add categories with images on homepage – magento

to add categories along with images on homepage

just add the code given below to your homepage from admininstration cms management.

{{block type="catalog/navigation" name="catalog.category" template="catalog/category/list.phtml"}}
Also you need to create a list.phtml file under “/app/design/frontend/default/default/template/catalog/category/list.phtml”
and add the below given code to it:
===========================================
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $open
= $this->isCategoryActive($_category); ?>
<?php
$cur_category
=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
if (
$immagine = $this->getCurrentCategory()->getImageUrl()):
?>

<div style="float: left; padding-right: 30px; text-align: center;">
<
div class="linkimage">
<
p>
<
a href="<?php echo $this->getCategoryUrl($_category)?>">
<
img src="<?php echo $immagine ?>" alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" width="135" height="135" />
<?php echo $_category->getName()?>
</a>
</
p>
</
div>
</
div>

<?php endif; ?>
<?php
endforeach; ?>

================================================
About these ads

19 Responses to “add categories with images on homepage – magento”

  1. phpcook Says:

    hi samsami2u
    really thanks :D

    i need your [personal mail id] thanks lot

      • rakesh purohit Says:

        hey sam,

        i need an help, i am using a Cms page as my home page for this i created an layout file in this file the container portion is static, where i putted a link to another CMS page where i want to show Category listing…as per iphone theme,,but on link it goes to that page but not showing anything in content,,,,,so how can i show Category listing in an CMS page???
        if u can add me Gtalk…..pls addd

  2. Coolen Says:

    What can we do wrong. We made the file and added {{block type=”catalog/navigation” name=”catalog.category” template=”catalog/category/list.phtml”}}

    But there is nothing to see. No errors either

  3. Thilaga Says:

    I agree,For me it’s not working

  4. Hazel Says:

    Same problem here. not showing up anything…

  5. Mark Says:

    Thanks,

    Works perfectly.

    Grtz

  6. Erwin Says:

    Just add this code, but I think it’s only applicable for the “head” categories and not the sub categories. I have my navigation under the producten page. Is it possible to show the sub categories on the homepage?
    Grtz,
    Erwin

  7. piero Says:

    Hi, thanks for this code, it works well. But i would like to add a static bloc between the homepage text and the {{block type=”catalog/navigation” name=”catalog.category” template=”catalog/category/list.phtml”}}, and a static bloc with css design, how to do it??

  8. kajal Says:

    For all who is seeking a real answer
    this is your php file save it in “/app/design/frontend/default/default/template/catalog/category/Your_file_name.phtml”
    getCurrentCategory();
    $collection = Mage::getModel(‘catalog/category’)->getCategories($_category->entity_id);
    $helper = Mage::helper(‘catalog/category’);
    ?>

    {{block type=”catalog/navigation” name=”catalog.category” template=”catalog/category/list.phtml”}}

    getIsActive()):?>
    load($cat->getId());
    $_img = $cur_category->getImageUrl();
    ?>

    <a href="getCategoryUrl($cat);?>”>
    <img src="” title=”$cat->getName()”/>
    getName();?>

    and you may call it from placing the following line in editor

    {{block type=”catalog/navigation” name=”catalog.category” template=”catalog/category/Your_file_name.phtml”}}

  9. Sahus Pilwal Says:

    Does anyone know whether this is still applicable for Magento CE v.1.4.1.1

    Any feedback greatly appreciated. Cheers ;)

  10. shruti sharma Says:

    It doesn’t work for me either oin 1.4 version. Can anybody tell me the reason.

  11. Joel Says:

    Did anyone get either of these techniques working in 1.4.2? I’m getting nothing on my cms page.

    • timopenstream Says:

      Are you sure you have images set up for your categories? The following condition is clipping out categories w/o images:

      if ($immagine = $this->getCurrentCategory()->getImageUrl()):

      Replace it with

      $immagine = $this->getCurrentCategory()->getImageUrl();

      and remove endif; in order to display all categories regardless if they have images or not. Also the following line is useless:

      isCategoryActive($_category); ?>

    • timopenstream Says:

      Looks like wp.com is clipping some code parts.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 25 other followers

%d bloggers like this: