A frequent request with customers is adding CMS pages to Magento’s top navigation. There are many ways to accomplish this, but the best way is to make it a static block so that clients can add or delete links by their own.

In Magento 1.9 the top links are now located in the following file/folder:

app/design/frontend/design-package/your-theme/template/page/html/topmenu.phtml.

The file should look like this when done:

<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
   <ul id="nav">
       <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('top-navbar-before')->toHtml() ?>
       <?php echo $_menu ?>
       <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('top-navbar-after')->toHtml() ?>
   </ul>
</div>
<?php endif ?>

Create these two static blocks as follows:

top-navbar-before:
<li><a href=”{{store direct_url=”/”}}”>HOME</a></li>

top-navbar-after:

<li><a href=”{{store direct_url=”/about”}}”>About Us</a> </li>
<li><a href=”{{store direct_url=”/herbal_supplements”}}”>Herbal Supplements</a>
<ul>
<li><a href=”{{store direct_url=”qanda”}}”> Q and A</a></li>
<li><a href=”{{store direct_url=”/references”}}”> References</a> </li>
<li><a href=”{{store direct_url=”/research_studies”}}”> Research Studies</a></li>
</ul>
</li>

Once you save your static blocks, they should be visible in the top navigation.

So, to recap, we have added two static blocks to the top menu, top-navbar-before and top-navbar-after.

We have added an list of links to those static blocks, which will display before and after the categories.

Please note:

1. If you use one theme, it’s best to change the topmenu.phtml on custom theme.

2. You should change the WYSIWYG to disable for default (System-configuration-content management), or the magento will add extra <ul> tags and the menu can’t display correctly.

0 Likes
429 Views

You may also like

Leave A Comment

Please enter your name. Please enter an valid email address. Please enter message.