Magento Mega Menu: Responsive Custom Menu MOD

Magento Mega Menu : Responsive Custom Menu MOD

Downloads

AttachmentSize
Package icon Navigation.php3.29 KB

Here is a modded Responsive Custom Menu I just did, adding named menu classes and positioning the custom block element above the menu items.

Why?

Original menu didn't have any unique class identifiers for menu items--it was partially unique, but nothing you can actually use to style any individual menu item.  Also I thought it made sense to have the custom block ABOVE the menu listing. After all, any custom element you want to show is likely going to be more important than the regular menu listing.

If you're interested in this, then simply download the attached Navigation.php or copy/paste over the following app/code/commmunity/WP/CustomMenu/Block/Navigation.php:

getIsActive()) return '';
        $html = array();
        $id = $category->getId();
        // --- Sub Categories ---
        $activeChildren = $this->_getActiveChildren($category, $level);
        // --- class for active category ---
        $active = ''; if ($this->isCategoryActive($category)) $active = ' act';
        $hasSubMenu = count($activeChildren);
        $catUrl = $this->getCategoryUrl($category);
        $html[] = '';
        $html = implode("\n", $html);
        return $html;
    }

    public function getTopMenuArray()
    {
        return $this->_topMenu;
    }

    public function getPopupMenuArray()
    {
        return $this->_popupMenu;
    }

    public function drawCustomMenuItem($category, $level = 0, $last = false)
    {
        $name = $this->escapeHtml($category->getName());
		
		$className = 'nav-' . strtolower(str_replace(' ', '-', $name));
        if (Mage::getStoreConfig('custom_menu/general/non_breaking_space')) {
            $name = str_replace(' ', ' ', $name);
        }
		if (!$category->getIsActive()) return;
        $htmlTop = array();
        $id = $category->getId();
        // --- Static Block ---
        $blockId = sprintf(self::CUSTOM_BLOCK_TEMPLATE, $id); // --- static block key
        #Mage::log($blockId);
        $collection = Mage::getModel('cms/block')->getCollection()
            ->addFieldToFilter('identifier', array(array('like' => $blockId . '_w%'), array('eq' => $blockId)))
            ->addFieldToFilter('is_active', 1);
        $blockId = $collection->getFirstItem()->getIdentifier();
        #Mage::log($blockId);
        $blockHtml = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($blockId)->toHtml();
        // --- Sub Categories ---
        $activeChildren = $this->_getActiveChildren($category, $level);
        // --- class for active category ---
        $active = ''; if ($this->isCategoryActive($category)) $active = ' act';
        // --- Popup functions for show ---
        $drawPopup = ($blockHtml || count($activeChildren));
        if ($drawPopup) {
            $htmlTop[] = '