1

How Do I exclude a Magento category from the main menu and still maintain it in the side bar. I have tried these two code I got while searching on Google by replacing the default magento to these but its not working

Here is the code

<?php $_menu = "" ?>
  <?php if($_menu): ?>
  <div class="nav-container">
  <ul id="nav">
  <?php foreach ($this->getStoreCategories() as $_category): ?>
  <?php if(stristr('71,70,69', $_category->getId()) === FALSE) : ?> 
  <?php echo $this->drawItem($_category) ?>
  <?php endif ?>
   <?php endforeach ?>

   <?php // echo $_menu ?>
    </ul>
   </div>
  <?php endif  ?>

And here is the second piece of code. Also I got this from googling.

 <?php $_menu = ''?>
  <?php foreach ($this->getStoreCategories() as $_category): ?>
  <?php $_menu .= $this->drawItem($_category) ?>
 <?php endforeach ?>
 <?php if ($_menu): ?>
   <div class="nav-container">
      <ul id="nav">
    <?php foreach ($this->getStoreCategories() as $_category): ?>
       <?php if (!in_array($_category->getId(), array(12,34,56))) : ?> <?php echo $this-     >drawItem($_category) ?>
      <?php endif; ?>
     <?php endforeach ?>
    </ul>
  </div>
  <?php endif; ?>

None of them seem to be working. I am using magento 1. 7.1

Thanks for your help

2
  • By "sidebar" do you mean the "Shop By" block of anchor categories? – clockworkgeek Oct 18 '14 at 11:00
  • No I have a side bar menu listing all categories – Stifboy Oct 18 '14 at 13:19
1

I suggest you try the "Include in Navigation Menu" option near the bottom of "Manage Categories" page in admin. It might not affect your sidebar as it does not affect all block types which list categories.

1
  • This should be up more, don't want people to think that it's only possible by altering code. A sidebar that's well written should support this (or atleast have its own option) – Toon Van Dooren Oct 20 '14 at 14:35
-1

First Make sure that your category ids 69,70,71 is exist or not.if it is correct then do the second method you have tried as, if(in_array($_category->getId(),array(69,70,71)==false):or simplyif(!in_array($_category->getId(),array(69,70,71)):. It should work.

1
  • 1
    When I use the second code with your recommendation I get a blank menu. No menu displays. – Stifboy Oct 18 '14 at 13:36

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.