Remove link from navigation












1














How do you remove links from the navigation? I have found posts that explain how to remove all parent links, but how do I just remove a specific link from the main navigation? I.e. if users click on it they won't be directed to anywhere.










share|improve this question














bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    1














    How do you remove links from the navigation? I have found posts that explain how to remove all parent links, but how do I just remove a specific link from the main navigation? I.e. if users click on it they won't be directed to anywhere.










    share|improve this question














    bumped to the homepage by Community yesterday


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      1












      1








      1







      How do you remove links from the navigation? I have found posts that explain how to remove all parent links, but how do I just remove a specific link from the main navigation? I.e. if users click on it they won't be directed to anywhere.










      share|improve this question













      How do you remove links from the navigation? I have found posts that explain how to remove all parent links, but how do I just remove a specific link from the main navigation? I.e. if users click on it they won't be directed to anywhere.







      magento-1.9 navigation link






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 8 '15 at 3:30









      user3217495user3217495

      129318




      129318





      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community yesterday


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          3 Answers
          3






          active

          oldest

          votes


















          0














          In Magento Main Menu Consider has a Categories, Sub Categories.



          If you want to remove that you can manage Categories form the Magento Banked it self like Include in Menu then Select No. You can set this setting form Magento Back-end Catalog >> Category >> Select any Category



          But If you want to add any custom in Header then You need to edit the code in Magento topMenu.phtml file.



          Add the Your link in <ul> Tag.



          Add The For Example demo.



          <li><a href="<?php echo $this->getUrl(); ?>"><?php echo $this->__('Home');?></a></li>


          Let me know if you have any query.






          share|improve this answer





















          • Hi, thank you for your response. Some of my categories have sub-categories and others don't. I am trying to navigate to a static block when users click on a specific menu category but it's diverting off to that page, so i'm thinking that if I can remove that link it might allow the static-block to open.
            – user3217495
            May 9 '15 at 5:14










          • So to explain further; I need to remove the link of one of my categories. I still want it to show so I don't want to turn it off in the categories section, but I don't want anything to happen when the user clicks. I checked 'topMenu.phtml' but it doesn't show my links in there.
            – user3217495
            May 11 '15 at 23:59



















          0














          This should be fairly simple to do



          Override app/code/core/Mage/Catalog/Block/Navigation.php in your local directory (or preferably in your custom module, needless to say DONT TOUCH CORE)



          Find the function _renderCategoryMenuItemHtml() and just comment out two lines. Done



          protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
          $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
          {
          if (!$category->getIsActive()) {
          return '';
          }
          $html = array();

          // get all children
          // If Flat Data enabled then use it but only on frontend
          $flatHelper = Mage::helper('catalog/category_flat');
          if ($flatHelper->isAvailable() && $flatHelper->isBuilt(true) && !Mage::app()->getStore()->isAdmin()) {
          $children = (array)$category->getChildrenNodes();
          $childrenCount = count($children);
          } else {
          $children = $category->getChildren();
          $childrenCount = $children->count();
          }
          $hasChildren = ($children && $childrenCount);

          // select active children
          $activeChildren = array();
          foreach ($children as $child) {
          if ($child->getIsActive()) {
          $activeChildren = $child;
          }
          }
          $activeChildrenCount = count($activeChildren);
          $hasActiveChildren = ($activeChildrenCount > 0);

          // prepare list item html classes
          $classes = array();
          $classes = 'level' . $level;
          $classes = 'nav-' . $this->_getItemPosition($level);
          if ($this->isCategoryActive($category)) {
          $classes = 'active';
          }
          $linkClass = '';
          if ($isOutermost && $outermostItemClass) {
          $classes = $outermostItemClass;
          $linkClass = ' class="'.$outermostItemClass.'"';
          }
          if ($isFirst) {
          $classes = 'first';
          }
          if ($isLast) {
          $classes = 'last';
          }
          if ($hasActiveChildren) {
          $classes = 'parent';
          }

          // prepare list item attributes
          $attributes = array();
          if (count($classes) > 0) {
          $attributes['class'] = implode(' ', $classes);
          }
          if ($hasActiveChildren && !$noEventAttributes) {
          $attributes['onmouseover'] = 'toggleMenu(this,1)';
          $attributes['onmouseout'] = 'toggleMenu(this,0)';
          }

          // assemble list item with attributes
          $htmlLi = '<li';
          foreach ($attributes as $attrName => $attrValue) {
          $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';
          }
          $htmlLi .= '>';
          $html = $htmlLi;

          // $html = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>'; // Comment this line to remove link
          $html = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
          // $html = '</a>'; //and Comment This line

          // render children
          $htmlChildren = '';
          $j = 0;
          foreach ($activeChildren as $child) {
          $htmlChildren .= $this->_renderCategoryMenuItemHtml(
          $child,
          ($level + 1),
          ($j == $activeChildrenCount - 1),
          ($j == 0),
          false,
          $outermostItemClass,
          $childrenWrapClass,
          $noEventAttributes
          );
          $j++;
          }
          if (!empty($htmlChildren)) {
          if ($childrenWrapClass) {
          $html = '<div class="' . $childrenWrapClass . '">';
          }
          $html = '<ul class="level' . $level . '">';
          $html = $htmlChildren;
          $html = '</ul>';
          if ($childrenWrapClass) {
          $html = '</div>';
          }
          }

          $html = '</li>';

          $html = implode("n", $html);
          return $html;
          }





          share|improve this answer





























            0














            Although the question is quite old, since it is still active and none of the answers have been accepted, I would like to answer it.



            Since the question is about how to remove a specific link from the main navigation, it can easily be done by javascript (there is no need to modify PHP files for this simple task).



            Suppose my HTML code for the navigation is like:



            <nav id="nav">
            <ol class="nav-primary">
            <li class="level0 nav-1 first parent">
            <a href="http://127.0.0.1/magento1/electronics.html" class="level0 has-children">Electronics</a>
            <ul class="level0">
            <li class="level1 nav-1-1 first last"><a href="http://127.0.0.1/magento1/electronics/mobile.html" class="level1 ">Mobile</a></li>
            </ul>
            </li>
            <li class="level0 nav-2 parent">
            <a class="level0 has-children">Furniture</a>
            <ul class="level0">
            <li class="level1 nav-2-1 first last"><a class="level1 ">Chairs</a></li>
            </ul>
            </li>
            <li class="level0 nav-3 last parent">
            <a href="http://127.0.0.1/magento1/books.html" class="level0 has-children">Books</a>
            <ul class="level0">
            <li class="level1 nav-3-1 first last"><a href="http://127.0.0.1/magento1/books/story-books.html" class="level1 ">Story Books</a></li>
            </ul>
            </li>
            </ol>
            </nav>


            and I have to remove href link from the second parent, i.e. Furniture, then my javascript code would look like:



            <script type="text/javascript">
            jQuery(document).ready(function() {
            jQuery("#nav .nav-2.level0 a").removeAttr("href");
            });
            </script>


            i.e. The code is simply finding the unique parent element and removing href attribute from it.






            share|improve this answer





















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "479"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f67128%2fremove-link-from-navigation%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              In Magento Main Menu Consider has a Categories, Sub Categories.



              If you want to remove that you can manage Categories form the Magento Banked it self like Include in Menu then Select No. You can set this setting form Magento Back-end Catalog >> Category >> Select any Category



              But If you want to add any custom in Header then You need to edit the code in Magento topMenu.phtml file.



              Add the Your link in <ul> Tag.



              Add The For Example demo.



              <li><a href="<?php echo $this->getUrl(); ?>"><?php echo $this->__('Home');?></a></li>


              Let me know if you have any query.






              share|improve this answer





















              • Hi, thank you for your response. Some of my categories have sub-categories and others don't. I am trying to navigate to a static block when users click on a specific menu category but it's diverting off to that page, so i'm thinking that if I can remove that link it might allow the static-block to open.
                – user3217495
                May 9 '15 at 5:14










              • So to explain further; I need to remove the link of one of my categories. I still want it to show so I don't want to turn it off in the categories section, but I don't want anything to happen when the user clicks. I checked 'topMenu.phtml' but it doesn't show my links in there.
                – user3217495
                May 11 '15 at 23:59
















              0














              In Magento Main Menu Consider has a Categories, Sub Categories.



              If you want to remove that you can manage Categories form the Magento Banked it self like Include in Menu then Select No. You can set this setting form Magento Back-end Catalog >> Category >> Select any Category



              But If you want to add any custom in Header then You need to edit the code in Magento topMenu.phtml file.



              Add the Your link in <ul> Tag.



              Add The For Example demo.



              <li><a href="<?php echo $this->getUrl(); ?>"><?php echo $this->__('Home');?></a></li>


              Let me know if you have any query.






              share|improve this answer





















              • Hi, thank you for your response. Some of my categories have sub-categories and others don't. I am trying to navigate to a static block when users click on a specific menu category but it's diverting off to that page, so i'm thinking that if I can remove that link it might allow the static-block to open.
                – user3217495
                May 9 '15 at 5:14










              • So to explain further; I need to remove the link of one of my categories. I still want it to show so I don't want to turn it off in the categories section, but I don't want anything to happen when the user clicks. I checked 'topMenu.phtml' but it doesn't show my links in there.
                – user3217495
                May 11 '15 at 23:59














              0












              0








              0






              In Magento Main Menu Consider has a Categories, Sub Categories.



              If you want to remove that you can manage Categories form the Magento Banked it self like Include in Menu then Select No. You can set this setting form Magento Back-end Catalog >> Category >> Select any Category



              But If you want to add any custom in Header then You need to edit the code in Magento topMenu.phtml file.



              Add the Your link in <ul> Tag.



              Add The For Example demo.



              <li><a href="<?php echo $this->getUrl(); ?>"><?php echo $this->__('Home');?></a></li>


              Let me know if you have any query.






              share|improve this answer












              In Magento Main Menu Consider has a Categories, Sub Categories.



              If you want to remove that you can manage Categories form the Magento Banked it self like Include in Menu then Select No. You can set this setting form Magento Back-end Catalog >> Category >> Select any Category



              But If you want to add any custom in Header then You need to edit the code in Magento topMenu.phtml file.



              Add the Your link in <ul> Tag.



              Add The For Example demo.



              <li><a href="<?php echo $this->getUrl(); ?>"><?php echo $this->__('Home');?></a></li>


              Let me know if you have any query.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 8 '15 at 4:28









              Keyul ShahKeyul Shah

              6,53963058




              6,53963058












              • Hi, thank you for your response. Some of my categories have sub-categories and others don't. I am trying to navigate to a static block when users click on a specific menu category but it's diverting off to that page, so i'm thinking that if I can remove that link it might allow the static-block to open.
                – user3217495
                May 9 '15 at 5:14










              • So to explain further; I need to remove the link of one of my categories. I still want it to show so I don't want to turn it off in the categories section, but I don't want anything to happen when the user clicks. I checked 'topMenu.phtml' but it doesn't show my links in there.
                – user3217495
                May 11 '15 at 23:59


















              • Hi, thank you for your response. Some of my categories have sub-categories and others don't. I am trying to navigate to a static block when users click on a specific menu category but it's diverting off to that page, so i'm thinking that if I can remove that link it might allow the static-block to open.
                – user3217495
                May 9 '15 at 5:14










              • So to explain further; I need to remove the link of one of my categories. I still want it to show so I don't want to turn it off in the categories section, but I don't want anything to happen when the user clicks. I checked 'topMenu.phtml' but it doesn't show my links in there.
                – user3217495
                May 11 '15 at 23:59
















              Hi, thank you for your response. Some of my categories have sub-categories and others don't. I am trying to navigate to a static block when users click on a specific menu category but it's diverting off to that page, so i'm thinking that if I can remove that link it might allow the static-block to open.
              – user3217495
              May 9 '15 at 5:14




              Hi, thank you for your response. Some of my categories have sub-categories and others don't. I am trying to navigate to a static block when users click on a specific menu category but it's diverting off to that page, so i'm thinking that if I can remove that link it might allow the static-block to open.
              – user3217495
              May 9 '15 at 5:14












              So to explain further; I need to remove the link of one of my categories. I still want it to show so I don't want to turn it off in the categories section, but I don't want anything to happen when the user clicks. I checked 'topMenu.phtml' but it doesn't show my links in there.
              – user3217495
              May 11 '15 at 23:59




              So to explain further; I need to remove the link of one of my categories. I still want it to show so I don't want to turn it off in the categories section, but I don't want anything to happen when the user clicks. I checked 'topMenu.phtml' but it doesn't show my links in there.
              – user3217495
              May 11 '15 at 23:59













              0














              This should be fairly simple to do



              Override app/code/core/Mage/Catalog/Block/Navigation.php in your local directory (or preferably in your custom module, needless to say DONT TOUCH CORE)



              Find the function _renderCategoryMenuItemHtml() and just comment out two lines. Done



              protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
              $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
              {
              if (!$category->getIsActive()) {
              return '';
              }
              $html = array();

              // get all children
              // If Flat Data enabled then use it but only on frontend
              $flatHelper = Mage::helper('catalog/category_flat');
              if ($flatHelper->isAvailable() && $flatHelper->isBuilt(true) && !Mage::app()->getStore()->isAdmin()) {
              $children = (array)$category->getChildrenNodes();
              $childrenCount = count($children);
              } else {
              $children = $category->getChildren();
              $childrenCount = $children->count();
              }
              $hasChildren = ($children && $childrenCount);

              // select active children
              $activeChildren = array();
              foreach ($children as $child) {
              if ($child->getIsActive()) {
              $activeChildren = $child;
              }
              }
              $activeChildrenCount = count($activeChildren);
              $hasActiveChildren = ($activeChildrenCount > 0);

              // prepare list item html classes
              $classes = array();
              $classes = 'level' . $level;
              $classes = 'nav-' . $this->_getItemPosition($level);
              if ($this->isCategoryActive($category)) {
              $classes = 'active';
              }
              $linkClass = '';
              if ($isOutermost && $outermostItemClass) {
              $classes = $outermostItemClass;
              $linkClass = ' class="'.$outermostItemClass.'"';
              }
              if ($isFirst) {
              $classes = 'first';
              }
              if ($isLast) {
              $classes = 'last';
              }
              if ($hasActiveChildren) {
              $classes = 'parent';
              }

              // prepare list item attributes
              $attributes = array();
              if (count($classes) > 0) {
              $attributes['class'] = implode(' ', $classes);
              }
              if ($hasActiveChildren && !$noEventAttributes) {
              $attributes['onmouseover'] = 'toggleMenu(this,1)';
              $attributes['onmouseout'] = 'toggleMenu(this,0)';
              }

              // assemble list item with attributes
              $htmlLi = '<li';
              foreach ($attributes as $attrName => $attrValue) {
              $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';
              }
              $htmlLi .= '>';
              $html = $htmlLi;

              // $html = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>'; // Comment this line to remove link
              $html = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
              // $html = '</a>'; //and Comment This line

              // render children
              $htmlChildren = '';
              $j = 0;
              foreach ($activeChildren as $child) {
              $htmlChildren .= $this->_renderCategoryMenuItemHtml(
              $child,
              ($level + 1),
              ($j == $activeChildrenCount - 1),
              ($j == 0),
              false,
              $outermostItemClass,
              $childrenWrapClass,
              $noEventAttributes
              );
              $j++;
              }
              if (!empty($htmlChildren)) {
              if ($childrenWrapClass) {
              $html = '<div class="' . $childrenWrapClass . '">';
              }
              $html = '<ul class="level' . $level . '">';
              $html = $htmlChildren;
              $html = '</ul>';
              if ($childrenWrapClass) {
              $html = '</div>';
              }
              }

              $html = '</li>';

              $html = implode("n", $html);
              return $html;
              }





              share|improve this answer


























                0














                This should be fairly simple to do



                Override app/code/core/Mage/Catalog/Block/Navigation.php in your local directory (or preferably in your custom module, needless to say DONT TOUCH CORE)



                Find the function _renderCategoryMenuItemHtml() and just comment out two lines. Done



                protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
                $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
                {
                if (!$category->getIsActive()) {
                return '';
                }
                $html = array();

                // get all children
                // If Flat Data enabled then use it but only on frontend
                $flatHelper = Mage::helper('catalog/category_flat');
                if ($flatHelper->isAvailable() && $flatHelper->isBuilt(true) && !Mage::app()->getStore()->isAdmin()) {
                $children = (array)$category->getChildrenNodes();
                $childrenCount = count($children);
                } else {
                $children = $category->getChildren();
                $childrenCount = $children->count();
                }
                $hasChildren = ($children && $childrenCount);

                // select active children
                $activeChildren = array();
                foreach ($children as $child) {
                if ($child->getIsActive()) {
                $activeChildren = $child;
                }
                }
                $activeChildrenCount = count($activeChildren);
                $hasActiveChildren = ($activeChildrenCount > 0);

                // prepare list item html classes
                $classes = array();
                $classes = 'level' . $level;
                $classes = 'nav-' . $this->_getItemPosition($level);
                if ($this->isCategoryActive($category)) {
                $classes = 'active';
                }
                $linkClass = '';
                if ($isOutermost && $outermostItemClass) {
                $classes = $outermostItemClass;
                $linkClass = ' class="'.$outermostItemClass.'"';
                }
                if ($isFirst) {
                $classes = 'first';
                }
                if ($isLast) {
                $classes = 'last';
                }
                if ($hasActiveChildren) {
                $classes = 'parent';
                }

                // prepare list item attributes
                $attributes = array();
                if (count($classes) > 0) {
                $attributes['class'] = implode(' ', $classes);
                }
                if ($hasActiveChildren && !$noEventAttributes) {
                $attributes['onmouseover'] = 'toggleMenu(this,1)';
                $attributes['onmouseout'] = 'toggleMenu(this,0)';
                }

                // assemble list item with attributes
                $htmlLi = '<li';
                foreach ($attributes as $attrName => $attrValue) {
                $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';
                }
                $htmlLi .= '>';
                $html = $htmlLi;

                // $html = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>'; // Comment this line to remove link
                $html = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                // $html = '</a>'; //and Comment This line

                // render children
                $htmlChildren = '';
                $j = 0;
                foreach ($activeChildren as $child) {
                $htmlChildren .= $this->_renderCategoryMenuItemHtml(
                $child,
                ($level + 1),
                ($j == $activeChildrenCount - 1),
                ($j == 0),
                false,
                $outermostItemClass,
                $childrenWrapClass,
                $noEventAttributes
                );
                $j++;
                }
                if (!empty($htmlChildren)) {
                if ($childrenWrapClass) {
                $html = '<div class="' . $childrenWrapClass . '">';
                }
                $html = '<ul class="level' . $level . '">';
                $html = $htmlChildren;
                $html = '</ul>';
                if ($childrenWrapClass) {
                $html = '</div>';
                }
                }

                $html = '</li>';

                $html = implode("n", $html);
                return $html;
                }





                share|improve this answer
























                  0












                  0








                  0






                  This should be fairly simple to do



                  Override app/code/core/Mage/Catalog/Block/Navigation.php in your local directory (or preferably in your custom module, needless to say DONT TOUCH CORE)



                  Find the function _renderCategoryMenuItemHtml() and just comment out two lines. Done



                  protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
                  $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
                  {
                  if (!$category->getIsActive()) {
                  return '';
                  }
                  $html = array();

                  // get all children
                  // If Flat Data enabled then use it but only on frontend
                  $flatHelper = Mage::helper('catalog/category_flat');
                  if ($flatHelper->isAvailable() && $flatHelper->isBuilt(true) && !Mage::app()->getStore()->isAdmin()) {
                  $children = (array)$category->getChildrenNodes();
                  $childrenCount = count($children);
                  } else {
                  $children = $category->getChildren();
                  $childrenCount = $children->count();
                  }
                  $hasChildren = ($children && $childrenCount);

                  // select active children
                  $activeChildren = array();
                  foreach ($children as $child) {
                  if ($child->getIsActive()) {
                  $activeChildren = $child;
                  }
                  }
                  $activeChildrenCount = count($activeChildren);
                  $hasActiveChildren = ($activeChildrenCount > 0);

                  // prepare list item html classes
                  $classes = array();
                  $classes = 'level' . $level;
                  $classes = 'nav-' . $this->_getItemPosition($level);
                  if ($this->isCategoryActive($category)) {
                  $classes = 'active';
                  }
                  $linkClass = '';
                  if ($isOutermost && $outermostItemClass) {
                  $classes = $outermostItemClass;
                  $linkClass = ' class="'.$outermostItemClass.'"';
                  }
                  if ($isFirst) {
                  $classes = 'first';
                  }
                  if ($isLast) {
                  $classes = 'last';
                  }
                  if ($hasActiveChildren) {
                  $classes = 'parent';
                  }

                  // prepare list item attributes
                  $attributes = array();
                  if (count($classes) > 0) {
                  $attributes['class'] = implode(' ', $classes);
                  }
                  if ($hasActiveChildren && !$noEventAttributes) {
                  $attributes['onmouseover'] = 'toggleMenu(this,1)';
                  $attributes['onmouseout'] = 'toggleMenu(this,0)';
                  }

                  // assemble list item with attributes
                  $htmlLi = '<li';
                  foreach ($attributes as $attrName => $attrValue) {
                  $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';
                  }
                  $htmlLi .= '>';
                  $html = $htmlLi;

                  // $html = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>'; // Comment this line to remove link
                  $html = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                  // $html = '</a>'; //and Comment This line

                  // render children
                  $htmlChildren = '';
                  $j = 0;
                  foreach ($activeChildren as $child) {
                  $htmlChildren .= $this->_renderCategoryMenuItemHtml(
                  $child,
                  ($level + 1),
                  ($j == $activeChildrenCount - 1),
                  ($j == 0),
                  false,
                  $outermostItemClass,
                  $childrenWrapClass,
                  $noEventAttributes
                  );
                  $j++;
                  }
                  if (!empty($htmlChildren)) {
                  if ($childrenWrapClass) {
                  $html = '<div class="' . $childrenWrapClass . '">';
                  }
                  $html = '<ul class="level' . $level . '">';
                  $html = $htmlChildren;
                  $html = '</ul>';
                  if ($childrenWrapClass) {
                  $html = '</div>';
                  }
                  }

                  $html = '</li>';

                  $html = implode("n", $html);
                  return $html;
                  }





                  share|improve this answer












                  This should be fairly simple to do



                  Override app/code/core/Mage/Catalog/Block/Navigation.php in your local directory (or preferably in your custom module, needless to say DONT TOUCH CORE)



                  Find the function _renderCategoryMenuItemHtml() and just comment out two lines. Done



                  protected function _renderCategoryMenuItemHtml($category, $level = 0, $isLast = false, $isFirst = false,
                  $isOutermost = false, $outermostItemClass = '', $childrenWrapClass = '', $noEventAttributes = false)
                  {
                  if (!$category->getIsActive()) {
                  return '';
                  }
                  $html = array();

                  // get all children
                  // If Flat Data enabled then use it but only on frontend
                  $flatHelper = Mage::helper('catalog/category_flat');
                  if ($flatHelper->isAvailable() && $flatHelper->isBuilt(true) && !Mage::app()->getStore()->isAdmin()) {
                  $children = (array)$category->getChildrenNodes();
                  $childrenCount = count($children);
                  } else {
                  $children = $category->getChildren();
                  $childrenCount = $children->count();
                  }
                  $hasChildren = ($children && $childrenCount);

                  // select active children
                  $activeChildren = array();
                  foreach ($children as $child) {
                  if ($child->getIsActive()) {
                  $activeChildren = $child;
                  }
                  }
                  $activeChildrenCount = count($activeChildren);
                  $hasActiveChildren = ($activeChildrenCount > 0);

                  // prepare list item html classes
                  $classes = array();
                  $classes = 'level' . $level;
                  $classes = 'nav-' . $this->_getItemPosition($level);
                  if ($this->isCategoryActive($category)) {
                  $classes = 'active';
                  }
                  $linkClass = '';
                  if ($isOutermost && $outermostItemClass) {
                  $classes = $outermostItemClass;
                  $linkClass = ' class="'.$outermostItemClass.'"';
                  }
                  if ($isFirst) {
                  $classes = 'first';
                  }
                  if ($isLast) {
                  $classes = 'last';
                  }
                  if ($hasActiveChildren) {
                  $classes = 'parent';
                  }

                  // prepare list item attributes
                  $attributes = array();
                  if (count($classes) > 0) {
                  $attributes['class'] = implode(' ', $classes);
                  }
                  if ($hasActiveChildren && !$noEventAttributes) {
                  $attributes['onmouseover'] = 'toggleMenu(this,1)';
                  $attributes['onmouseout'] = 'toggleMenu(this,0)';
                  }

                  // assemble list item with attributes
                  $htmlLi = '<li';
                  foreach ($attributes as $attrName => $attrValue) {
                  $htmlLi .= ' ' . $attrName . '="' . str_replace('"', '"', $attrValue) . '"';
                  }
                  $htmlLi .= '>';
                  $html = $htmlLi;

                  // $html = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>'; // Comment this line to remove link
                  $html = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
                  // $html = '</a>'; //and Comment This line

                  // render children
                  $htmlChildren = '';
                  $j = 0;
                  foreach ($activeChildren as $child) {
                  $htmlChildren .= $this->_renderCategoryMenuItemHtml(
                  $child,
                  ($level + 1),
                  ($j == $activeChildrenCount - 1),
                  ($j == 0),
                  false,
                  $outermostItemClass,
                  $childrenWrapClass,
                  $noEventAttributes
                  );
                  $j++;
                  }
                  if (!empty($htmlChildren)) {
                  if ($childrenWrapClass) {
                  $html = '<div class="' . $childrenWrapClass . '">';
                  }
                  $html = '<ul class="level' . $level . '">';
                  $html = $htmlChildren;
                  $html = '</ul>';
                  if ($childrenWrapClass) {
                  $html = '</div>';
                  }
                  }

                  $html = '</li>';

                  $html = implode("n", $html);
                  return $html;
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 23 '17 at 9:57









                  Kumar A.Kumar A.

                  393315




                  393315























                      0














                      Although the question is quite old, since it is still active and none of the answers have been accepted, I would like to answer it.



                      Since the question is about how to remove a specific link from the main navigation, it can easily be done by javascript (there is no need to modify PHP files for this simple task).



                      Suppose my HTML code for the navigation is like:



                      <nav id="nav">
                      <ol class="nav-primary">
                      <li class="level0 nav-1 first parent">
                      <a href="http://127.0.0.1/magento1/electronics.html" class="level0 has-children">Electronics</a>
                      <ul class="level0">
                      <li class="level1 nav-1-1 first last"><a href="http://127.0.0.1/magento1/electronics/mobile.html" class="level1 ">Mobile</a></li>
                      </ul>
                      </li>
                      <li class="level0 nav-2 parent">
                      <a class="level0 has-children">Furniture</a>
                      <ul class="level0">
                      <li class="level1 nav-2-1 first last"><a class="level1 ">Chairs</a></li>
                      </ul>
                      </li>
                      <li class="level0 nav-3 last parent">
                      <a href="http://127.0.0.1/magento1/books.html" class="level0 has-children">Books</a>
                      <ul class="level0">
                      <li class="level1 nav-3-1 first last"><a href="http://127.0.0.1/magento1/books/story-books.html" class="level1 ">Story Books</a></li>
                      </ul>
                      </li>
                      </ol>
                      </nav>


                      and I have to remove href link from the second parent, i.e. Furniture, then my javascript code would look like:



                      <script type="text/javascript">
                      jQuery(document).ready(function() {
                      jQuery("#nav .nav-2.level0 a").removeAttr("href");
                      });
                      </script>


                      i.e. The code is simply finding the unique parent element and removing href attribute from it.






                      share|improve this answer


























                        0














                        Although the question is quite old, since it is still active and none of the answers have been accepted, I would like to answer it.



                        Since the question is about how to remove a specific link from the main navigation, it can easily be done by javascript (there is no need to modify PHP files for this simple task).



                        Suppose my HTML code for the navigation is like:



                        <nav id="nav">
                        <ol class="nav-primary">
                        <li class="level0 nav-1 first parent">
                        <a href="http://127.0.0.1/magento1/electronics.html" class="level0 has-children">Electronics</a>
                        <ul class="level0">
                        <li class="level1 nav-1-1 first last"><a href="http://127.0.0.1/magento1/electronics/mobile.html" class="level1 ">Mobile</a></li>
                        </ul>
                        </li>
                        <li class="level0 nav-2 parent">
                        <a class="level0 has-children">Furniture</a>
                        <ul class="level0">
                        <li class="level1 nav-2-1 first last"><a class="level1 ">Chairs</a></li>
                        </ul>
                        </li>
                        <li class="level0 nav-3 last parent">
                        <a href="http://127.0.0.1/magento1/books.html" class="level0 has-children">Books</a>
                        <ul class="level0">
                        <li class="level1 nav-3-1 first last"><a href="http://127.0.0.1/magento1/books/story-books.html" class="level1 ">Story Books</a></li>
                        </ul>
                        </li>
                        </ol>
                        </nav>


                        and I have to remove href link from the second parent, i.e. Furniture, then my javascript code would look like:



                        <script type="text/javascript">
                        jQuery(document).ready(function() {
                        jQuery("#nav .nav-2.level0 a").removeAttr("href");
                        });
                        </script>


                        i.e. The code is simply finding the unique parent element and removing href attribute from it.






                        share|improve this answer
























                          0












                          0








                          0






                          Although the question is quite old, since it is still active and none of the answers have been accepted, I would like to answer it.



                          Since the question is about how to remove a specific link from the main navigation, it can easily be done by javascript (there is no need to modify PHP files for this simple task).



                          Suppose my HTML code for the navigation is like:



                          <nav id="nav">
                          <ol class="nav-primary">
                          <li class="level0 nav-1 first parent">
                          <a href="http://127.0.0.1/magento1/electronics.html" class="level0 has-children">Electronics</a>
                          <ul class="level0">
                          <li class="level1 nav-1-1 first last"><a href="http://127.0.0.1/magento1/electronics/mobile.html" class="level1 ">Mobile</a></li>
                          </ul>
                          </li>
                          <li class="level0 nav-2 parent">
                          <a class="level0 has-children">Furniture</a>
                          <ul class="level0">
                          <li class="level1 nav-2-1 first last"><a class="level1 ">Chairs</a></li>
                          </ul>
                          </li>
                          <li class="level0 nav-3 last parent">
                          <a href="http://127.0.0.1/magento1/books.html" class="level0 has-children">Books</a>
                          <ul class="level0">
                          <li class="level1 nav-3-1 first last"><a href="http://127.0.0.1/magento1/books/story-books.html" class="level1 ">Story Books</a></li>
                          </ul>
                          </li>
                          </ol>
                          </nav>


                          and I have to remove href link from the second parent, i.e. Furniture, then my javascript code would look like:



                          <script type="text/javascript">
                          jQuery(document).ready(function() {
                          jQuery("#nav .nav-2.level0 a").removeAttr("href");
                          });
                          </script>


                          i.e. The code is simply finding the unique parent element and removing href attribute from it.






                          share|improve this answer












                          Although the question is quite old, since it is still active and none of the answers have been accepted, I would like to answer it.



                          Since the question is about how to remove a specific link from the main navigation, it can easily be done by javascript (there is no need to modify PHP files for this simple task).



                          Suppose my HTML code for the navigation is like:



                          <nav id="nav">
                          <ol class="nav-primary">
                          <li class="level0 nav-1 first parent">
                          <a href="http://127.0.0.1/magento1/electronics.html" class="level0 has-children">Electronics</a>
                          <ul class="level0">
                          <li class="level1 nav-1-1 first last"><a href="http://127.0.0.1/magento1/electronics/mobile.html" class="level1 ">Mobile</a></li>
                          </ul>
                          </li>
                          <li class="level0 nav-2 parent">
                          <a class="level0 has-children">Furniture</a>
                          <ul class="level0">
                          <li class="level1 nav-2-1 first last"><a class="level1 ">Chairs</a></li>
                          </ul>
                          </li>
                          <li class="level0 nav-3 last parent">
                          <a href="http://127.0.0.1/magento1/books.html" class="level0 has-children">Books</a>
                          <ul class="level0">
                          <li class="level1 nav-3-1 first last"><a href="http://127.0.0.1/magento1/books/story-books.html" class="level1 ">Story Books</a></li>
                          </ul>
                          </li>
                          </ol>
                          </nav>


                          and I have to remove href link from the second parent, i.e. Furniture, then my javascript code would look like:



                          <script type="text/javascript">
                          jQuery(document).ready(function() {
                          jQuery("#nav .nav-2.level0 a").removeAttr("href");
                          });
                          </script>


                          i.e. The code is simply finding the unique parent element and removing href attribute from it.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered May 25 '18 at 7:33









                          Mohit Kumar AroraMohit Kumar Arora

                          6,28841532




                          6,28841532






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f67128%2fremove-link-from-navigation%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              An IMO inspired problem

                              Management

                              Investment