In this tutorial we will show you a quick example of how you can edit a OpenCart template to change the default layout that is used for your OpenCart site.

As an example let's say you have created a gift voucher in OpenCart. By default it's just going to show a link for customers to redeem their gift voucher at the bottom of the page in your site map. If you don't have your categories menu at the top filled all the way up, adding a link to your gift vouchers in this menu might be handy for your customers.

Edit the OpenCart header template

By default when you install OpenCart all of the templates will be located in the following directory:

/catalog/view/theme/default/template/

  1. Open up the File Manager Code Editor in cPanel.
  2. navigate to common template directoryNavigate to the following directory in the File Manager:

    /catalog/view/theme/default/template/common/
  3. Right click on the header.tpl file and select Code Edit.

    If the encoding check pop-up displays, you can simply click Edit

  4. done editing header template click on save changesAround line 93 will be where the menu at at the top of your page completes. You'll want to insert a link to your gift voucher page here. The link you'll want to use should look like this:

    <li><a href="/support/./index.php?route=account/voucher">Gift Voucher</a></li>

    The section of code that you're adding this to is the DIV with the ID menu, the full code once you're done should look like this:

    <div id="menu">
    <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="/support/<?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="/support/<?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="/support/./index.php?route=account/voucher">Gift Voucher</li>
    </ul>

    Once you're done making your modification, click on Save Changes at the top right.

Now you should have a nice visible link to your gift vouchers right in your top menu, instead of tucked away down in the bottom menu. Here is a before and after showing what this change accomplished:



Before:
opencart categories header-before


After:
opencart categories header after
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve our Support Center:
Email Address
Optional, but our team may contact you for more information.
Like this Article?

Post a Comment

Name:
Email Address:
Comment:
Are you a bot?
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Write New!
Do you want to publish a tutorial to our support center?

News / Announcements

SSL Certficate Warnings
Updated 2014-04-14 11:34 am EST
Hits: 2004
Heartbleed 0-day OpenSSL security bug
Updated 2014-04-14 04:43 pm EST
Hits: 5279

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!