How to add a custom link to the top navigation in Magento

By default, Magento's top navigation contains links to your product categories. But what if you want to add a custom link there? In this article we will show you how to add a custom link to the top navigation in Magento.

The file that contains the code for the top navigation is called top.phtml and its location may vary depending on your template. For the default Magento template the full path to the file is:

app/design/frontend/base/default/template/catalog/navigation/top.phtml

You can edit the file by downloading it with your favorite FTP client, opening it with a text editor (e.g. Notepad), making the changes and then uploading it back to your Magento directory.

Another way to edit the file would be to connect to your account via SSH and open it with vim or nano. The customers have free SSH access to their accounts and can edit the file directly on the server.

A third way of editing the file would be to use some of the tools your control panel provides. The customers can edit the file using the File Manager in their control panel.

Once you open the file, scroll down to its bottom and find this section:

<div class="nav-container">

<ul id="nav">

<?php echo $_menu ?>

</ul>

</div>

To add a link that will appear in the top navigation, you need to add the following line inside the <ul> tags:

<li><a href="http://somedomain.com"><span>Your Link</span></a></li>

Let's say that you want to create a link called Web Hosting that will open the site http://www.yourserver.com. The above section in the top.phtml file should look like this:

 

<div class="nav-container">

<ul id="nav">

<?php echo $_menu ?>

<li><a href="http://www.yourserver.com"><span>Web Hosting</span></a></li>

</ul>

</div>

 

Flush the Magento cache and reload your front page to see the new link in your Magento top navigation.

 
  • 0 Users Found This Useful
這篇文章有幫助嗎?

相關文章

How to add and edit static pages in Magento

To add and edit CMS static pages, log in to the admin panel of your Magento store and go to...

How to add and edit admin users and user roles in Magento

In addition to the admin account that's created while installing your Magento you can add more...

Test CRON

From time to time, we might want to test Magento's CRON.An easy way to test if it does run well...

How to add and manage currencies in Magento

In Magento you can allow customers to view the prices of the products in your shop in different...

Reset Files and Directories permissions

From time to times, we must fix permissions on files and directory in order to secure an...