fter reading this most I revised the code to get the layout matching the grid layout in Magento 1.5: http://www.magentocommerce.com/boards/viewreply/162813/
1. In cms select Static Blocks
- Set the Block Identifyer to for example “Sub Category Listing”
- Set the Identifyer to “subcategory_listing”
- In the content section write:
{{block type="catalog/navigation" template="catalog/navigation/subcategory_listing.phtml"}}
2. Now take the code below and paste it into a new file called "subcategory_listing.phtml" this file needs to live in the "catalog/navigation" directory:
<div class="category-products">
<ul class="products-grid">
<?php
$_categories=$this->getCurrentChildCategories();
if($_categories->count()):
$categorycount = 0;
foreach ($_categories as $_category):
if($_category->getIsActive()):
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
$catName = $this->getCurrentCategory()->getName();
if ($categorycount == 0){
$class = "first";
}
elseif ($categorycount == 3){
$class = "last";
}
else{
$class = "";
}
?>
<li class="item <?=$class?>">
<a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><img src="<?php echo $this->getCurrentCategory()->getThumbnailUrl() ?>" width="100" alt="<?php echo $this->htmlEscape($_category->getName()) ?>" /></a>
<h2><a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>"><?php echo $this->htmlEscape($_category->getName()) ?></a></h2>
</li>
<?php
endif;
if($categorycount == 3){
$categorycount = 0;
echo "</ul>\n\n<ul class=\"products-grid\">";
}
else{
$categorycount++;
}
endforeach;
endif;
?>
</ul>
</div>
3. Now Goto Manage Categories.
- Pick a Category whose subcategories you’d like displayed
- Set the display mode to “Static Block Only” or “Static Block and Products”
- From the CMS Block dropdown select the Static Page “Sub Category Listing”
Important!! You must do this unless Magento have introduced getThumbnailUrl():
A very nice solution, I was looking for exactly this same thing. What would I need to put in the code to stop the thumb and subcategory title displaying if the category has no thumbnail?
I haven't tried it but does this work?:
thanks a lot Keiron for this great tutorial…….. :)
Great tutorial Keiron but for some reason I am unable to get the thumbnail to show.
http://noveltyspot.totalwebuk.co.uk/store/anal-toys.html
excuse the content, it's for a client not me!! :-)
I'm getting:
Fatal error: Call to a member function count() on a non-object in /home/walleffe/public_html/app/design/frontend/base/default/template/catalog/navigation/subcategory_listing.phtml on line 5
in 1.5.0.1
Any ideas?
It's cool, I found the answer at http://www.magentocommerce.com/boards/viewthread/37795/#t124101
Thanks for this, works great! One weird thing I noticed, is that when I'm viewing a category that is using this, my left nav will always show the last sub-category under that root category as active.
So, for example, let's say I have a "Main Category" that has three sub-categories, "sub-category 3" will always show as active in the left navigation.
Any one else notice this problem and perhaps have a solution? :)
I did everything like Keiron wrote but for some reason I am unable to get the thumbnail to show. I have got Magento 1.4.1.1
Please help
Do you have a url for the page(s) you're having problems with?
Is there any way to achieve the same result without hacking the core category.php file?
Hi there, Great example, just wondering if there is a line of code you could add to make the categories list alphabetically.
Hello,
you can pass getCurrentCategory()->getImageUrl() ?> for display subcategory images.
Hey, great script.
But when we have updated our Magento to 1.7.0.2 the thumbnails arent displaying anymore. only the name of the sub category stands there
example link