Create a menu from CMS pages in Magento

cms

Use the following code to create a menu using CMS pages in Magento.  I have used this code in footer.phtml to add a menu of links.  With some css it really turns out nice.

Add to this if statement to exclude CMS pages from the list:

            if($data[‘identifier’]==’no-route’)
                continue;

Modify the code like this to exclude a page with an id of about-us:

            if($data[‘identifier’]==’no-route’ || $data[‘identifier’]==’about-us’)
                continue;

Here is the code:

<?php
$store = Mage::app()->getStore();
$cms_pages = Mage::getModel('cms/page')->getCollection();
$cms_pages->addStoreFilter($store);
$cms_pages->load();

echo '<ul>'. "\r\n";

foreach ($cms_pages as $_page) {
$data = $_page->getData();

if($data['identifier']=='no-route') # Add to this to exclude more pages.
continue;

echo '<li><a href="'.Mage::getURL().$data['identifier'].'" title="'.$data['title'].'" target="_self">'.$data['title'].'</a></li>'."\r\n";

}
echo '</ul>' . "\r\n";
?>