Guest User

Untitled

a guest
Jan 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass) {
  2.  
  3. $html = '';
  4.  
  5. $children = $menuTree->getChildren();
  6.  
  7. $parentLevel = $menuTree->getLevel();
  8. $childLevel = is_null($parentLevel) ? 0 : $parentLevel + 1;
  9.  
  10. $counter = 1;
  11. $childrenCount = $children->count();
  12.  
  13. $parentPositionClass = $menuTree->getPositionClass();
  14. $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
  15.  
  16. foreach ($children as $child) {
  17. $child->setLevel($childLevel);
  18. $child->setIsFirst($counter == 1);
  19. $child->setIsLast($counter == $childrenCount);
  20. $child->setPositionClass($itemPositionClassPrefix . $counter);
  21.  
  22. $outermostClassCode = '';
  23. $outermostClass = $menuTree->getOutermostClass();
  24.  
  25. if ($childLevel == 0 && $outermostClass) {
  26. $outermostClassCode = ' class="' . $outermostClass . '" ';
  27. $child->setClass($outermostClass);
  28. }
  29. $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
  30. $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'
  31. . $this->escapeHtml($child->getName()) . '</span></a>';
  32.  
  33. if ($child->hasChildren()) {
  34. if (!empty($childrenWrapClass)) {
  35. $html .= '<div class="' . $childrenWrapClass . '">';
  36. }
  37. $html .= '<ul class="level' . $childLevel . '">';
  38. $html .= $this->_getHtml($child, $childrenWrapClass);
  39. $html .= '</ul>';
  40.  
  41. if (!empty($childrenWrapClass)) {
  42. $html .= '</div>';
  43. }
  44. }
  45. $html .= '</li>';
  46.  
  47. $counter++;
  48. }
  49.  
  50. return $html;
  51. }
  52.  
  53. $splittedArray = explode($delimiter = 'category-node-', $child->getId());
  54. $category = Mage::getModel('catalog/category')->load(end($splittedArray));
  55. $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
  56. if (!empty($category->getData('image'))) {
  57. $html .= '<div> ';
  58. $html .= "<a href=" . $category->getURL() . " title =" . $category->getName() . ">";
  59. $html .= "<img src=" . Mage::getBaseUrl('media') . 'catalog/category/' . $category->getData('image') . " alt=" . $category->getName() . " >";
  60. $html .= "</a>";
  61. $html .= '</div>';
  62. }
Add Comment
Please, Sign In to add comment