1

Recently I changed some parent menu name and it's path(Those parent menus are all categories, not cms pages), now I find out those parents menu that has subcategories are unclickable, it can only show the subcategories when hover on I can click subcategories.

But the Parent Menu without subcategories still clickable.

I'm wondering how can I make this parent menu clickable again? Thanks

-1
$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-child' : '';

    if ($child->getCssNav() != '') {
        $child->setClass($child->getCssNav());
    }

    $html .= '<li '.$this->_getRenderedMenuItemAttributes($child).'>';

    switch ($child->getCssNav()) {
        case 'grille':
            $class = $child->getVisuelMenu() ? 'with-image' : '';
            $html .= '<a href="'.$child->getUrl().'" class="'.$outermostClassCode.' '.$_hasChildren.' '.$class.' item">';
            if ($child->getVisuelMenu() != '') {
                $url = Mage::getBaseUrl('media').'catalog/category/'.$child->getVisuelMenu();
                $html .= '<img src="'.$url.'" alt="'.$this->escapeHtml($this->__($child->getName())).'" width="70" height="70" />';
            }
            $html .= $this->escapeHtml($this->__($child->getName()));
            $html .= '</a>';
            break;
        case 'selection':
            $html .= '<a href="'.$child->getUrl().'" class="'.$outermostClassCode.' '.$_hasChildren.' item">'.$this->escapeHtml($this->__($child->getName())).'</a>';
            if ($child->getVisuelMenu() != '') {
                $url = Mage::getBaseUrl('media').'catalog/category/'.$child->getVisuelMenu();
                $html .= '<div class="push"><a href="'.$child->getUrl().'"><img src="'.$url.'" alt="'.$this->escapeHtml($this->__($child->getName())).'" /></a></div>';
            }
            break;
        default:
            $html .= '<a href="'.$child->getUrl().'" class="'.$outermostClassCode.' '.$_hasChildren.' item">'.$this->escapeHtml($this->__($child->getName())).'</a>';
            break;
    }

    if (!empty($childrenWrapClass)) {
        $html .= '<div class="'.$childrenWrapClass.'">';
    }

    $nextChildLevel = $childLevel + 1;

    if (!empty($_hasChildren)) {
        $extraClass = '';
        if ($childLevel == 0) {
            $extraClass = 'cd-secondary-nav';
        }

        //affichage du moteur de recherche ds le menu
        if ($child->getCssNav() == 'filtre') {
            $html .= '<div class="level'.$childLevel.' ul '.$extraClass.' is-hidden" id="'.$child->getId().'">';
            $html .= '<div class="input-search"><input class="search-'.$child->getId().'" placeholder="Filtrer..." /></div>';
            $html .= '<ul class="level'.$childLevel.' list">';
        } else {
            $html .= '<div class="level'.$childLevel.' ul '.$extraClass.' is-hidden">';
            $html .= '<ul class="level'.$childLevel.'">';
        }

        //utile pour la navigation mobile
        $html .= '<li class="go-back"><a href="#0">'.$this->__('Menu').'</a></li>';
        $html .= $this->render($child, $childrenWrapClass);
        $html .= '</ul>';
        $html .= '</div>';
    }

    if (!empty($childrenWrapClass)) {
        $html .= '</div>';
    }

    $html .= '</li>';

    ++$counter;
}

return $html;
// this is what i have in my code
  • Welcome to Magento SE. If you post code as an answer, please at least explain briefly what this code is doing and where it belongs. Answers with code but no explanation are rarely useful. – Fabian Schmengler Apr 27 '17 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.