First copy topmenu.phtml from
/app/design/frontend/rwd/default/template/page/html/
Save this file as topmenu.phtml to
/app/design/frontend/YOUR PACKAGE/YOUR THEME/template/page/html/
Edit this file within lines 38-40, paste the following:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('home-link')->toHtml(); ?>
To create:
<ol class="nav-primary">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('home-link')->toHtml(); ?>
<?php echo $_menu ?>
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('post-menu-links')->toHtml(); ?>
</ol>
Save and re-upload this file.
Create a CMS > Static Block
, named home-link
enter the following into your block (Hide Editor, as needed):
<li class="level0 nav-1 parent"><a href='{{config path="web/unsecure/base_url"}}' title='Home Page' class='level0'>Home</a></li>
Note: I leave all of the class names consistent with 1.9. Feel free to adjust class names as needed.
Save your new Static Block.
Create a CMS > Static Block
, named post-menu-links
Enter the following into your block (Hide Editor, as needed):
<li class="level0 nav-1 parent"><a href="CUSTOMPATH-1.HTML" title="LINK TITLE #1" class="level0">LINKNAME #1</a></li>
<li class="level0 nav-1 parent"><a href="CUSTOMPATH-2.HTML" title="LINK TITLE #2" class="level0">LINKNAME #2</a></li>
<!-- and so on, as needed ... -->
Save your new Static Block.
Be sure to clear the cache and refresh your browser.
Here is the proper way to add a cms page link to the main menu without using the event page_block_html_topmenu_gethtml_before
.
This way you will be able to add an active state to it also.
So create an observer in one of your modules that can look like this:
public function addCmsPage($observer)
{
//your page identifier
$cmsPageIdentifier = 'page_idendifier_here';
//get the menu instance
$menu = $observer->getMenu();
//load the page
$page = Mage::getModel('cms/page')->load($cmsPageIdentifier, $identifier);
//if the page exists
if ($page->getId()) {
$active = false;
// Get the full action name for the request.
$fullActionName = Mage::app()->getFrontController()->getAction()->getFullActionName();
//check if we are on the view page action for the required page
if ($fullActionName == 'cms_page_view') {
$pageId = Mage::app()->getRequest()->getParam('page_id', $this->getRequest()->getParam('id', false));
if ($pageId == $page->getId()) {
$active = true;
}
}
//build a new menu item node
$data = array(
'name' => $page->getTitle(),
'id' => 'cms-'.$cmsPageIdentifier,
'url' => Mage::getUrl('', array('_direct'=>$cmsPageIdentifier)),
'is_active' => $active
);
$pageNode = new Varien_Data_Tree_Node($data, 'id', $tree, $menu);
//attach the node to the menu
$menu->addChild($pageNode);
}
}
Best Answer
here is an example of adding home link to nav, with active class if you need it
this need to be added to topmenu.phtml