I couldn’t find an option anywhere to add the category images into the category menu so I modified the code myself to add them in. Here is what I changed:
app\code\core\Mage\Catalog\Block\Navigation.php
Line 104
public function getCategoryUrl($category) { return Mage::getModel('catalog/category') ->setData($category->getData()) ->getCategoryUrl(); }
//Start Edit public function getImageUrl($category) { return Mage::getModel('catalog/category') ->setData($category->getData()) ->getImageUrl(); } //End Edit
Added new function called getImageUrl that accesses app\code\core\Mage\Catalog\Model\Category.php getImageUrl() to get the image name.
Then I added a new function in the same file below the existing function drawItem() to display the images with each item:
//Start Edit public function drawItemwithImage($category, $level=0, $last=false) { $html = ''; if (!$category->getIsActive()) { return $html; }
Then I had to create a new .phtml template to use this new functionality:
app\design\frontend\OC\default\template\catalog\navigation\category_singlelevel_image.phtml
(You will need to replace “OC” with your template name or “default” to use this code)
<ul class="products"> <?foreach ($this->getStoreCategories(1) as $_category):?> <?=$this->drawItemwithImage($_category)?> <?endforeach?> </ul>
Then finally I could use the new template section in the default.xml to display the cateogry list with images:
app\design\frontend\OC\default\layout\core\default.xml
(You will need to replace “OC” with your template name or “default” to use this code)
Interesting. I didn’t see any spot to add an image either. I wonder why this was left out? Maybe they didn’t get to it in time. There’s quite a bit to do after all.
Now, this works fine for retrieving the subcategories and displaying them. The problem lies with retrieving the category image urls, no matter what I try these always come back blank.