2

As per my requirement in current project i need to place custom menu which should have general pages as menu items like Home,About Us etc but in basically we get categories as nav-menu in magento so how to do this.

2
  • what theme do you use?
    – dh47
    Commented Dec 22, 2014 at 9:41
  • I use RWD theme
    – Abdul
    Commented Dec 22, 2014 at 9:41

4 Answers 4

8

Goto app/design/frontend/rwd/default/template/page/html and open topmenu.phtml file. find this code

<?php if($_menu): ?>
    <nav id="nav">
        <ol class="nav-primary">
            <?php echo $_menu ?>
        </ol>
    </nav>
<?php endif ?>

this code will output you the categories in the form of top menu if you don't use any categories hide this code or else paste this code before or after this code.

<ul>
            <li><a href="<?php echo Mage::getBaseUrl(); ?>">HOME</a></li>
            <li><a href="<?php echo Mage::getBaseUrl(); ?>aboutus">ABOUT US</a></li>
            <li><a href="<?php echo Mage::getBaseUrl(); ?>your_page_uri">your_page_name</a></li>
            <li><a href="<?php echo Mage::getBaseUrl(); ?>your_page_uri">your_page_name</a></li>

</ul>
1
  • The problem with this if you add to categories that have first and last classes, it causes CSS issues.
    – rybo111
    Commented Jul 20, 2015 at 10:47
2

Another way to do it would be to use Observer page_block_html_topmenu_gethtml_before and then you can alter the menu in the way magento is doing it itself. For more information on that, like how to build up a real structure you can take a look here: http://inchoo.net/ecommerce/adding-links-to-the-top-menu-in-magento/

3
  • thanks for the answer but the above answer looks easier :)
    – Abdul
    Commented Dec 22, 2014 at 10:04
  • This is good.! But I have a dumb question - where do I find the config.xml as stated in above url.?
    – CodeRomeos
    Commented Sep 28, 2015 at 17:15
  • In the module that you use for changing the menu. Commented Sep 29, 2015 at 11:14
1

Adding links to top menu in magento

Step 1: Create a config file under app/code/local/Bootsgrid/Shipping/etc/config.xml

within config tag.

<frontend>
<events>
    <page_block_html_topmenu_gethtml_before>
        <observers>
            <bootsgrid_shipping>
                <class>bootsgrid_shipping/observer</class>
                <method>addToTopmenu</method>
            </bootsgrid_shipping>
        </observers>
    </page_block_html_topmenu_gethtml_before>
</events></frontend>

Step 2: Create a observer into app/code/local/Bootsgrid/Shipping/Model/Observer.php

 class Bootsgrid_Shipping_Model_Observer
{
    public function addToTopmenu(Varien_Event_Observer $observer)
    {
        $menu = $observer->getMenu();
        $tree = $menu->getTree();
        $node = new Varien_Data_Tree_Node(array(
            'name'   => 'Store Pickup',
            'id'     => 'storepickup',
            'url'    => Mage::getUrl('storepickup') // Link url
        ), 'id', $tree, $menu);
        $menu->addChild($node);
    }
}

output: https://prnt.sc/lgksr5

Hope this will helps to you.

0

You can also have both....

Just create 1 category which will be shown in the navigation with all your product-categories below. (so it will be 1 pull down entry in your menu) Afterwards create different extra main categories (Home, About Us etc etc) and put in your .htaccess file a 301 redirect so if the menu wants them to be directed to the (empty) category About Us it will redirect them to the /aboutus CMS page.

I think this redirection is a main requirement for almost all shops.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.