In Magento i have added categories and subcategories,these will be displayed in home page of my website.
Now, I want to display subcategories along with respective image. But I do not want to use any extensions provided by Magento.
Below snapshot shows how my dropdown menu looks, but i want to add image to respective category.
This is the code which i have added in renderer.phtml app/design/frontend/rwd/default/template/page/html/topmenu
<?php
$html = '';
$children = $menuTree->getChildren();
$parentLevel = $menuTree->getLevel();
$childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
$counter = 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
foreach ($children as $child) {
$child->setLevel($childLevel);
$child->setIsFirst($counter == 1);
$child->setIsLast($counter == $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = 'level'. $childLevel;
$_hasChildren = ($child->hasChildren()) ? 'has-children' : '';
$html .= '<li '. $this->_getRenderedMenuItemAttributes($child) .'>';
$html .= '<a href="'. $child->getUrl() .'" class="'. $outermostClassCode .' '. $_hasChildren .'">'. $this->escapeHtml($this->__($child->getName())) .'</a>';
if (!empty($childrenWrapClass)) {
$html .= '<div class="'. $childrenWrapClass .'">';
}
$nextChildLevel = $childLevel + 1;
if (!empty($_hasChildren)) {
$html .= '<ul class="level'. $childLevel .'">';
$html .= '<li class="level'. $nextChildLevel .' view-all">';
$html .= '<a class="level'. $nextChildLevel .'" href="'. $child->getUrl() .'">';
$html .= $this->__('View All') . ' ' . $this->escapeHtml($this->__($child->getName()));
$html .= '</a>';
$html .= '</li>';
$html .= $this->render($child, $childrenWrapClass);
$html .= '</ul>';
}
if (!empty($childrenWrapClass)) {
$html .= '</div>';
}
$html .= '</li>';
$counter++;
}
return $html;
and following code i have added in app/design/frontend/rwd/default/template/page/html/topmenu.phtml
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<nav id="nav">
<ol class="nav-primary">
<?php echo $_menu ?>
</ol>
</nav>
<?php endif ?>
and also i have added following code in app/etc/modules/WP_customMenu.xml to display the category list in customized form
<?xml version="1.0"?>
<config>
<modules>
<WP_CustomMenu>
<active>true</active>
<codePool>community</codePool>
</WP_CustomMenu>
</modules>
</config>