Skip to content

Instantly share code, notes, and snippets.

@ho-nl
Created March 11, 2011 10:03
Show Gist options
  • Save ho-nl/865684 to your computer and use it in GitHub Desktop.
Save ho-nl/865684 to your computer and use it in GitHub Desktop.
public function getThumbnailUrl()
{
$url = false;
if ($image = $this->getThumbnail()) {
$url = Mage::getBaseUrl('media').'catalog/category/'.$image;
}
return $url;
}
public function getImageUrl($category)
{
return Mage::getModel('catalog/category')->load($category->getId())->getImageUrl();
}
public function getThumbnailUrl($category)
{
return Mage::getModel('catalog/category')->load($category->getId())->getThumbnailUrl();
}
public function drawItem($category, $level = 0, $last = false, $rendermode)
{
return $this->_renderCategoryMenuItemHtml($category, $level, $last, null, null, null, null, null, $rendermode);
}
protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
$isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false, $rendermode)
if($rendermode == 'image' && $this->getImageUrl($category)){
$html[] = '<img src="'.$this->getImageUrl($category).'" />';
}else if($rendermode == 'thumbnail' && $this->getThumbnailUrl($category)){
$html[] = '<img src="'.$this->getThumbnailUrl($category).'" />';
}
<li class="level-top"><a class="level-top" href="#"><?php echo $this->__('Your parent'); ?></a>
<ul class="level0">
<?php foreach ($this->getStoreCategories() as $_category):?>
<?php
if ($_category->getId() == '3') {
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = (array)$_category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $_category->getChildren();
$childrenCount = $children->count();
}
if ( $childrenCount ) {
$this_id = $_category->getId();
foreach ( $children as $child ) {
echo $this->drawItem($child);
}
}
}
?>
<?php endforeach ?>
</ul>
</li>
echo $this->drawItem($child, 0, true,'thumbnail');
@ho-nl
Copy link
Author

ho-nl commented Mar 25, 2011

This solution is part of our blog post: Using category images in your Magento navigation. Please subscribe to our RSS or follow us on Twitter for tips & tricks, free Magento extensions and more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment