Sunday 15 April 2012

php - How Do I exclude a Magento category from the main menu -



php - How Do I exclude a Magento category from the main menu -

how exclude magento category main menu , still maintain in side bar. have tried these 2 code got while searching on google replacing default magento these not working

here code

<?php $_menu = "" ?> <?php if($_menu): ?> <div class="nav-container"> <ul id="nav"> <?php foreach ($this->getstorecategories() $_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 sec piece of code. got googling.

<?php $_menu = ''?> <?php foreach ($this->getstorecategories() $_category): ?> <?php $_menu .= $this->drawitem($_category) ?> <?php endforeach ?> <?php if ($_menu): ?> <div class="nav-container"> <ul id="nav"> <?php foreach ($this->getstorecategories() $_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 working. using magento 1. 7.1

thanks help

to exclude category top navigation menu retain category in left side menu. whether menu items should show in top navigation menu can controlled in admin. have perform next steps:

firstly, create boolean category attribute code 'use_in_navigation' using info upgrade script:

$installer = $this; $installer->startsetup(); $installer->addattribute('catalog_category', 'use_in_navigation', array( 'type' => 'int', 'input' => 'select', 'label' => 'use in navigation', 'required' => false, 'note' => '', 'user_defined' => '1', 'source' => 'eav/entity_attribute_source_boolean', 'default' => false)); $entitytypeid = $installer->getentitytypeid('catalog_category'); $attributesetid = $installer->getdefaultattributesetid($entitytypeid); $installer->addattributetogroup( $entitytypeid, $attributesetid, 'general information', 'use_in_navigation', 100); $installer->endsetup();

secondly, override "_gethtml" "mage_page_block_html_topmenu" , skip rendering of children 'use_in_navigation' false:

protected function _gethtml(varien_data_tree_node $menutree, $childrenwrapclass){ .... foreach ($children $child) { if(!$child->getuseinnavigation()){ continue; } .... } }

something along these lines should trick.

note: function names have been taken magento ce 1.8. might differ magento ce 1.7.

php css magento magento-1.7

No comments:

Post a Comment