Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.

Getting all CMS pages dynamically in Magento

Paste the below code in your header to get all your CMS pages dynamically in Magento.

<!-- new script for displaying the home navigation -->

<?php $collection = Mage::getModel('cms/page')->getCollection()->addStoreFilter(Mage::app()->getStore()->getId());?>
<?php  $collection->getSelect()->where('is_active = 1'); ?>
<?php foreach ($collection as $page): ?>
<?php $PageData = $page->getData(); ?>
<?php //print_r($PageData);?>
<?php if($PageData['identifier']!='no-route' && $PageData['identifier']!='enable-cookies' && $PageData['identifier']!='home2') { ?>
<?php if($PageData['identifier'] == 'payment-on-delivery' || $PageData['identifier'] == 'nationwide-delivery'){ ?>
<a href="<?php echo $this->getUrl($PageData['identifier']) ; ?>"><?php echo $PageData['title'] ?></a>
<?php } ?>
<?php } ?>
<?php endforeach; ?>

<!--  End of the home navigation -->

Hope it is helpful.

comments powered by Disqus