2

I need some help. I'm using Magento CE 1.9.2.1.

How can I make all parent categories of the top navigation menu non-clickable? Basically, I only want the menu categories that DON'T have any subcategories to be clickable.

I have 4 levels of categories and I only want the last one to be clickable.

I saw some tutorials but they all are for version 1.8 and lower. With the RWD theme it's all different now and I wasn't sure where to look.

Also, it would be great, as a bonus, to make the breadcrumb appear but not be clickable except the home link.

Thanks in advance!

asked Aug 16, 2015 at 4:15

2 Answers 2

2

Top Navigation Menu Non-Clickable

  • Open app/design/frontend/rwd/default/template/page/html/topmenu/renderer.phtml
  • Edit the following line of code:

    // COMMENT OUT THIS LINE
    //$html .= '<a href="'. $child->getUrl() .'" class="'. $outermostClassCode .' '. $_hasChildren .'">'. $this->escapeHtml($this->__($child->getName())) .'</a>';
    // ADD THESE LINES
    if (!empty($_hasChildren)) {
     $html .= '<a onclick="return false" style="text-decoration:none; cursor: default;" href="javascript:;" class="'. $outermostClassCode .' '. $_hasChildren .'">'. $this->escapeHtml($this->__($child->getName())) .'</a>';
    } else {
     $html .= '<a href="'. $child->getUrl() .'" class="'. $outermostClassCode .' '. $_hasChildren .'">'. $this->escapeHtml($this->__($child->getName())) .'</a>';
    }
    

Breadcrumb Non-Clickable

  • Edit this file app/design/frontend/base/default/template/page/html/breadcrumbs.phtml
  • You can add an IF condition to display link to Homepage only, like this:

    <?php if ($this->escapeHtml($_crumbInfo['label']) == 'Home'): ?>
     <a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a>
    <?php else: ?> 
     <a href="javascript:;" onclick="return false" style="text-decoration: none; cursor: default;" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a>
    <?php endif; ?> 
    
answered Aug 16, 2015 at 7:30
3
  • Thanks, Mukesh. This solution worked great but on a non-touch device only. Once a touch device (iPhone) was used, the menu became inoperable. Any ideas? Commented Aug 16, 2015 at 11:30
  • I have updated the answer. Can you try it again on touch devices? Commented Aug 16, 2015 at 11:40
  • Works perfectly on all devices now! Thanks a lot for your help, Mukesh. Commented Aug 16, 2015 at 13:18
0

This answer helped point me in the correct direction, though make sure you are not using an extension which overrides default behavior. We had an extension Templates Master Navigation Pro and it was in a different location to edit in a similar way. Turning on template hints is always a good way to find out which template you need to edit and helped me end up finding the exact location to edit.

System -> Configuration -> (Advanced) Developer -> Template Hints (change Scope to correct view)

Though in our case I had to search our codebase for some identifying CSS selectors to find the Controller which was creating the proper object which was output after finding the template where that object was being rendered.

answered Aug 7, 2017 at 22:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.