Put CMS pages in Header Menu in Magento

Hi Friends !! After long time, I am back in blogging and posting some interesting stuffs for you.

Today I will show you that how you can change your header menu in magento and how you can put CMS pages in header dynamic menu.

In one of my project, I have faced the problem that how to change mail menu and how to put CMS pages in main menu.

After long search in google, i found the solution which I want  to share with you. If you want to change you header in Magento, Please follow below steps :

First open top.phtml file of your template. My path for this file is /public_html/app/design/frontend/default/hellostyle/template/catalog/navigation/top.phtml.

Now after this, Remove default menu code like this :

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

And Add this code here :

<?php $collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());?>
<?php  $collection->getSelect()
->where('is_active = 1'); ?>
<ul id="nav">
<?php foreach ($collection as $page): ?>
<?php $PageData = $page->getData(); ?>
<?php if($PageData['identifier']!='no-route' && $PageData['identifier']!='enable-cookies' && $PageData['identifier']!='home2') { ?>
<li>
<a href="/<?php echo $PageData['identifier']?>"><span><?php echo $PageData['title'] ?></span></a>
</li>
<?php } ?>
<?php endforeach; ?>
</ul>

Thats it ! Now you can see all the CMS pages in header.

If you have any problem or any query in this or if you want any help from myside, just comment on this.

Thanks !

  • Miss_tarelea

    what if i want to keep some menu item coming from categories and at the same time i want that to include in menu navigation bar the CMS pages. thank you

  • Rizecorp

    Thanks for posting and Its good to see you again.

  • http://www.programmingfacts.com PHP Freelancer

    Good One.. Keep it up.. I hope this time you will keep posting instead of coming back again and again. :)

  • Nel

    Thanks so much for this.  Saved me ;)

  • Klarzahs

    Great one ;-) Thanks alot.

  • Salim Kureshi

    thanks alot dear,

    you have to save my time….

  • Survi

    It is working great.But the cms page link is not working.need help….

  • Malik

    it does not working

  • Anonymous

    great

  • Egergerg

    rgegegrer gergergreg

  • Drew

    How do we have the subpages show as a second level list?

  • gaurav

    great thanks a lot

  • vishwa

    i need help for cms pages menu by categories menu i have to display in same list in top header page ,is it possible?

  • joseph12

    The navigation in the header of a Magento Go store usually lists the top-level categories from the catalog.Keep reading this.Thanks for sharing it.

  • http://www.magentodevelopments.com/ magento development india

    Magento provides a lot of versatility for Magento concept style, but it needs a bit of looking and discovering before one can understand to do a new easy technique. In the Magento traditional style, it reveals us how to position a resilient callout prevent in the remaining variety by using the

    Example of the concept is in the choice.xml, right in the position.

    images/media/col_left_callout.jpg
    Our client
    support is available 24/7. Contact us at (800)
    DEMO-NUMBER.
    checkout/cart

  • sumiti

    hiii i pu this code but there is no active class for menus