Pages

Friday 28 September 2012

dynamic cms page link in magento || show all cms pages links in top navigation

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>

now your all cms page links will be displayed in top navigation in default magento(CE)

No comments:

Post a Comment