Today I want to write a short article about adding their arbitrary links to the main menu. By default, the template displays only checked category in the menu, but sometimes we need instead of categories or with them, to withdraw its reference for example About us, contacts, delivery, payment, documents, etc. ..
Well let's start:
(PS: This method may differ on non-standard templates)
All of the code of the main menu is in the file header.tpl that lies here:
1 |
catalog/view/theme/default/template/common/header.tpl |
Open the file in notepad ++ our favorite find in it the code which is responsible for the menu:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<div id="menu"> <ul> <?php foreach ($categories as $category) { ?> <li><?php if ($category['active']) { ?> <a href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a> <?php } else { ?> <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a> <?php } ?> <?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> |
And change it to your code like this:
1 2 3 4 5 6 7 8 |
<div id="menu"> <ul> <li><a href="/">About company</a></li> <li><a href="/">Shipping and payment</a></li> <li><a href="/">Answers on questions</a></li> <li><a href="/">Connect with us</a></li> </ul> </div> |
So we completely removed all output categories and add your links.
If you need to display links together then just add them after the closing tag li
Just like that, we have changed the top menu, try to comment, ask questions!
No Comment
You can post first response comment.