Jun 28, 2011
admin

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….

PHP Genious Services

I am a PHP freelancer india, PHP Developer india, PHP programmer india, Wordpress Freelancer india, Wordpress customization services, Wordpress Plugin Developer, Wordpress theme customization, Wordpress plugin customization, Magento Freelancer, Magento Developer india, Magento customization services, Magento theme integration, Opencart Developer india, Zencart Freelancer, Opencart customization, Opencart plugin development, HTML and CSS customization, cakePHP Developer, cakePHP Freelancer india, Ecommerce Developer india

Click Here for

Follow me on Facebook

Categories

Get Adobe Flash playerPlugin by wpburn.com wordpress themes