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 A felhasználók hasznosnak találták ezt
Hasznosnak találta ezt a választ?

Kapcsolódó cikkek

Why is Magento cron job not working?

cPanel + CageFS and CloudLinux's PHP switcher may cause problems with Magento CRON. Until this is...

Reset Files and Directories permissions

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

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 product ratings and reviews in Magento

In Magento each product can be rated and reviewed. Customers (both guests and registered ones)...

Numeric value out of range: 1690 BIGINT UNSIGNED

Description Recently when making some cleanup on a Magento based store that was having over 550K...