Latest Articles
So far this was never an issue, there were problems with uploading modules via the installer because of the ftp connection but you could allways install ocmods without any issue. However, some .. Read More
People had this issue so many times I thought I would write a bit about it. The  types of issues with opencart's 2.x modification system that I identified so far are: 1. Old Vqmod .. Read More
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize.. Read More
To enable seo urls in opencart navigate in admin to system > settings , edit the store and on the server tab of the store settings you will find "Use SEO urls", set it to yes. So far e.. Read More
All Articles

Add custom links in opencart top menu - opencart 1.5.x

This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize your top menu have a look at my Supermenu module.

To add a link to the default top category menu in opencart you will have to edit the file catalog/view/theme/yourtheme/template/common/header.tpl and if you have the default theme or some theme that didnt modify the top menu structure, in header.tpl the code of the top menu will look something like this:

<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?>

You can add custom links before or after the opencart categories in the menu. In the above code you will see a custom link placed before the categories and one after, and using the same structure you can add more custom links by copy/pasting the line(s) and then modify the url and the name of the link.

<?php if ($categories) { ?>
<div id="menu">
  <ul>
   <li><a href="link-url">Link Name(before categories)</a></li>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
   <li><a href="link-url">Link Name(after categories)</a></li>
  </ul>
</div>
<?php } ?>

If you are using my news/blog module and you want to add a link to the blog headlines page to the top menu and you dont have supermenu , this is the way to do it.

Posted by Flo

Products related to this article

FlyOut Mega Menu module v3 text_reviews
Compatible: Opencart 1.5.2.x to 1.5.6.4 - 2.0.1 - 2.0.1.1 - 2.0.2 - 2.0.3.1 - 2.1.0.1 - 2.1.0.2 - 2.2.0.0 - 2.3.0.0 - 2.3.0.2
$15.00 $10.00
Super Mega Menu V2.4 - opencart module text_reviews
Compatible: Opencart 1.5.2.x to 2.0 - 2.0.1.x - 2.0.2.x - 2.0.3.x - 2.1.0.x - 2.2.0.0 - 2.3.0.x - 3.0.0.0 - 3.0.1.x - 3.0.2.x
$15.00 $12.00

Related Articles

  Having your own online store can be a great opportunity to gain money. One of the best advantages is that you do not have to invest a fortune to start it. All you need is a website and little basic knowledge. If you do not know anything, do not worry you will find plenty of tutorials on the internet. In this tutorial, you will learn how to install modules in opencart 1.5.1. It is not hard and you will be able to do it yourself as soon as you finish reading. It is true that if you are used to the older versions of Opencart, it may seem a little bit different however, the steps tha..
1 comments on this article - view comments
There are many feature that the new OpenCart 1.5x has. However, some of the most important ones are those who have remained from the previous versions. Attributes are one of the greatest things for e-commerce in general and especially for OpenCart. This way you can add features for the products you sell and in the same time, you can help your customers to compare products based on their feature. Even more, they will be able to search for the things that they want based on the features that they need for a certain product. This is a nice thing and your visitors will definitely love this poss..
5 comments on this article - view comments
This small tutorial will show you how to manually add custom links to the default top menu in opencart. If you dont want to go trough all the hustle and would like to be able to completly customize your top menu have a look at my Supermenu module. To add a link to the default top category menu in opencart you will have to edit the file catalog/view/theme/yourtheme/template/common/header.tpl and if you have the default theme or some theme that didnt modify the top menu structure, in header.tpl the code of the top menu will look something like this: <?php if ($categories) ..
5 comments on this article - view comments

1 Comments To "Add custom links in opencart top menu - opencart 1.5.x"

yousuf On 09 Apr 2016
this is very helpful.. how can i add dropdown after adding custom menu? i have tried but it is not working Reply to this comment

Write a comment

Your Name:


Enter the code in the box below:

Your Comment:
Note: HTML is not translated!