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!
2 Answers 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
IFcondition 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; ?>
-
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?Dan– Dan2015年08月16日 11:30:22 +00:00Commented Aug 16, 2015 at 11:30
-
I have updated the answer. Can you try it again on touch devices?Mukesh Chapagain– Mukesh Chapagain2015年08月16日 11:40:19 +00:00Commented Aug 16, 2015 at 11:40
-
Works perfectly on all devices now! Thanks a lot for your help, Mukesh.Dan– Dan2015年08月16日 13:18:09 +00:00Commented Aug 16, 2015 at 13:18
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.