Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Exclude specific catagories from top menu
 
puntable
Member
 
Avatar
Total Posts:  50
Joined:  2011-02-24
Denmark
 

Hello

I want to exclude specific catagories from my top menu, but not exclude them from my right menu.
The problem is, i have so many catagories the dont fit in the top menu, so therefore i only want certain catagories to be shown in the top menu and all catagories to be shown in my right column.

I am running v. 1.7.0.1

I tried this solution, but i cant get it to work.

Any help would be greatly appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
michaelmac
Member
 
Total Posts:  40
Joined:  2012-05-28
 

I doubt this is the best method however you could put whatever you want in the top menu.

Then create a custom phtml layout to create a block that pulls in all your categories.

Such as:

<div id="block">

<
h3>Shop By Category</h3>
<?php
     
/* Get the categories that are active for the store */
      
$_main_categories=$this->getStoreCategories();
      
/* Get the current category the user is in */
      
$_current_category=$this->getCurrentCategory();
      
/* Get the current category path */
      
$_categorypath $this->getCurrentCategoryPath();
      
?>
      
<ul>
          
<?php
              
if ($_main_categories):
                  
/* This bit cycles through the categories - setting the next one to current */
                  
foreach ($_main_categories as $_main_category):
                  
                    if(
$_main_category->getIsActive()):                             
                         
$cur_category=Mage::getModel('catalog/category')->load($_main_category->getId());
                         
$layer Mage::getSingleton('catalog/layer');
                         
$layer->setCurrentCategory($cur_category);
                              
                          
/* Write the main categories */           
                        
?> 
                                        
                        
<li class="root-nav"><a href="<?php echo $this->getCurrentCategory()->getUrl()?>"><?php echo $this->getCurrentCategory()->getName();?></a></li>   
                    
                        
<?php $_maincategorylisting=$this->getCurrentCategory()?>                       
                        <?php $_categories
=$this->getCurrentChildCategories()?>
                        <?php 
if($_categories->count()):?>
                          
                        
<ul>
                              
<? foreach ($_categories as $_category):?>                   
                                 
                                  <? 
if($_category->getIsActive()):                   
                                        
$cur_subcategory=Mage::getModel('catalog/category')->load($_category->getId());
                                             
$layer Mage::getSingleton('catalog/layer');
                                             
$layer->setCurrentCategory($cur_subcategory); 
                                  
?>  
                                                         
                                  
<li class="sub-nav"><a href="<?php echo $this->getCategoryUrl($_category)?>"<?php echo $_category->getName()?></a></li>
                                      
                                    
<? endif;?>
                            
                             <?endforeach?>
                         
</ul>  
               
                          
<?php /* This resets the category back to the original pages category
                          ****     If this is not done, subsequent calls on the same page will use the last category
                          ****    in the foreach loop
                          */   
?>
                          
                          <?php $layer
->setCurrentCategory($_current_category);  ?>
      
                      <?endif
;?>   
                                 
              <?php         
                  
endif;
              endforeach;
      else:
              
?>
      
<p>$_main_categories array was empty.</p>
      <
p>This might be because you are referencing this phtml file with a wrong type attributeYou should use <block type="catalog/navigation" ... /> !</p>
      
<?php endif; ?>
</ul>

</
div>

Just note this code may or may not work, its something i did and never tested

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top