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.
4 Answers
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>
-
The problem with this if you add to categories that have
first
andlast
classes, it causes CSS issues.– rybo111Commented Jul 20, 2015 at 10:47
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/
-
-
This is good.! But I have a dumb question - where do I find the config.xml as stated in above url.? Commented Sep 28, 2015 at 17:15
-
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.
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.