tags:

views:

3799

answers:

5

Hi there, I'm building a Magento store and want to be able to display a list of categories and have each category link to its own page.

I have a 'Brands' category with an ID of 42 and I want to display a list of the sub-categories and ensure that each one links to the designated URL key in the CMS.

Has anyone had experience of doing this with Magento?

Thank you.

A: 

This question requires a long answer. I will point you to the right places.

1) Best solution is to use the free extension. I haven't tried it, but it will suit the purpose. You will have to do some CSS to achieve the right look and feel.

http://www.magentocommerce.com/extension/1562/magento-easy-catalog-images Demo: http://extension01.templates-master.com/gb/electronics.html

2) I do not trust in modules as it might become difficult to upgrade if the vendor decided to stop supporting it. I have used the information from the following forum thread to create a vew sites. Have a look... Might not be straight forward. You might have to make some copies of core files to the local directory.

http://www.magentocommerce.com/boards/viewthread/3770/P30/

Hopefully this will be of help to you :)

Sid Vel
+1  A: 

If you're comfortable editing your theme, this code snippet will bring you a list of all sub-categories of the current category (from the session, so this should work anywhere in your theme). I typically use this in app/design/frontend/default/*theme_name*/template/catalog/category/view.phtml

<?php
$_category  = $this->getCurrentCategory(); 
$collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
$helper     = Mage::helper('catalog/category');
?>

<ul>
    <?foreach ($collection as $cat):?>
      <?php if($_category->getIsActive()):?>
             <?php 
                     $cur_category = Mage::getModel('catalog/category')->load($cat->getId());
                  $_img = $cur_category->getImageUrl();  
             ?>
          <li>
        <a href="<?php echo $helper->getCategoryUrl($cat);?>">
             <img src="<?php echo $_img?>" title="$cat->getName()"/>
             <cite><?php echo $cat->getName();?></cite>
        </a>
       </li>
      <?php endif?>
    <?php endforeach;?>
</ul>
wookiehangover
Thanks wookie, this worked like a charm.Just out of curiosity, I have seen a number of threads on the Magento forums that suggest using CMS static block to link to a separate PHP file to achieve this (http://www.magentocommerce.com/boards/viewthread/14527/P15/). To me it seems to be a bit OTT when we can easily add the code above into the view.phtml file. Are you aware of the reasons for their suggestions?
Matt
ya, I'm not sure why you'd want to do that. Part of the problem with magento is that it's so tough to do basic stuff in a custom theme that people end up creating really obtuse solutions rather than by using the resources that are readily accessible (but poorly documented).
wookiehangover
A: 

I made this little video on how I create custom category listing blocks with Magento. I am sure there are better ways of achieving this or even something I could have done better, but it’s just my method. I only created this it in hopes that it helps explain somethings to some people out there.

Magento Custom Category Listing Block

Thanks!

Devin R. Olsen
A: 

after looking at all the solutions on the magento site, i found that wookiehangover's solution above worked and took about 8 seconds to implement.

creates a UL that you can style. thanks.

Jason
A: 

Thanks! Works a treat.

Richard Graham