Add Home Link with functional active state to Menu Bar (Alternative Method)
This is an old revision of the document!
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>


