December 13, 2015

Magento - How to add static page link to main menu?

- Hello friends finally I find the solution for add static page link to main menu in magento CMS,

- First find the top.phtml file from this page: app/design/frontend/default/YourThemeName/template/catalog/navigation/top.phtml

- Before do any changes on this file please take copy of orignal top.phtml file,

- Below is default code of top.phtml file:


<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
       <?php echo $_menu ?>
    </ul>
</div>
<?php endif ?>

- You shoud modified as per below example where I add Home link:

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
     <li><a href="/">Home</a><li>
     <?php echo $_menu ?>
    </ul>
</div>
<?php endif ?>

- Or you should also add and magento block shord code (In block you define static menu link in <ul><li> format):

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
     <li><a href="/">Home</a><li>
     <?php echo $_menu ?>
     <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('navbar_links')->toHtml() ?>  
   </ul>
</div>
<?php endif ?>

- In above example 'navbar_links' is block identifier name.


Enjoy!

2 comments:

Integrating Google reCAPTCHA v3 in HTML Form with PHP

  What is Google reCAPTCHA v3? Google reCAPTCHA is a free service that helps protect websites from spam and abuse. reCAPTCHA v3 is the lates...