How To: Add Home Link to Menu Bar

For the Home link in the menu bar of the main template you can add some code to one of the template files.

Find the file called top.phtml in app/design/frontend/default/default/template/catalog/navigation/ and make the following change:

<div class="header-nav-container">
    <div class="header-nav">
        <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
        <ul id="nav">
 
        <!-- HOME BUTTON HACK -->
        <li><a href="<?php echo $this->getUrl('')?>"><?php echo $this->__('Home') ?></a></li>
        <!-- HOME BUTTON HACK -->
 
        <?php foreach ($this->getStoreCategories(10) as $_category):?>
            <?php echo $this->drawItem($_category) ?>
        <?php endforeach ?>
        </ul>
    </div>
    <?php echo $this->getChildHtml('topLeftLinks') ?>
</div>

 

If you want the home button to behave as te rest (get the active class when activated) change the above code to the following: (beware this is just as an hack as the previous example, but still, it works)

<div class="header-nav-container">
    <div class="header-nav">
        <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
        <ul id="nav">
 
    $_SERVER['REQUEST_URI'] == '/' ? $root = 'active' : $root = '';
 
        <!-- HOME BUTTON HACK -->
        <li class="<?php echo $root ?>"><a href="<?php echo $this->getUrl('')?>"><?php echo $this->__('Home') ?></a></li>
        <!-- HOME BUTTON HACK -->
 
        <?php foreach ($this->getStoreCategories(10) as $_category):?>
            <?php echo $this->drawItem($_category) ?>
        <?php endforeach ?>
        </ul>
    </div>
    <?php echo $this->getChildHtml('topLeftLinks') ?>
</div>
  • Email, SSL
  • 27 Users Found This Useful
Was this answer helpful?

Related Articles

How To: Setup Multiple Store for Magento

The following is the recommended guide to setup a Magento Multi-Store on our hosting plans. A...

How To: Display Products on Homepage

There are numerous ways to put products on your home page, and we’ll compile a list of code...

How To: Remove Add to Cart buttons from Catalog Pages

If you want to remove the “Add to Cart” buttons from the catalog pages, this is how...

How To: Create A PHP Info File

A PHP info file displays information about your PHP installation that can be useful to...

How To: Install Magento using Installatron Script Installer

There are a few easy steps that you will need to take to install Magento using Installatron...