Magento CMS 页面侧导航 - 需要排序列表

Magento CMS pages side nav - need to sort list

我正在使用此代码在 Magento 中创建动态丢失的 CMS 页面,它工作正常,但我想按字母顺序对其进行排序,但我不知道该怎么做

    <?php
$cmsPages = Mage::getModel('cms/page')->getCollection()
            ->addStoreFilter(Mage::app()->getStore()->getId())
            ->addFieldToFilter('is_active',1)
            ->addFieldToFilter('identifier', array(
                array(
                    'nin' => array(
                            'home',
                            'no-route',
                            'enable-cookies',
                            'thank-you',
                            'home-demo',
                            'empty'
                        )
                    )
                )
            );

?>

<style type="text/css">
    #cms-navigation a.active { color: red; }​
</style>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
    var url = window.location.pathname,
    urlRegExp = new RegExp(url.replace(/\/$/,'') + "$");
    jQuery('#cms-navigation a').each(function(){
        if(urlRegExp.test(this.href.replace(/\/$/,''))){
            jQuery(this).addClass('active');
        }
    });
 });
 </script>

<div class="block">
    <div class="block-title">
        <strong><span>CMS Navigation</span></strong>
    </div>
    <div class="block-content">
        <ul id="cms-navigation" style="padding: 10px;">
            <?php    



            foreach($cmsPages as $_cms):
                    $page = $_cms->getData();
                    //sort ($_cms->getData('title'));

                ?>
                <li><a href="<?php echo $this->getBaseUrl() . $page['identifier']; ?>"><?php echo $_cms['title']; ?></a></li>
                <?php

                 endforeach;

                 ?>

        </ul>
    </div>
</div>

你可以看到我在哪里注释掉了我的排序尝试,我已经尝试了几乎所有我能想到的但现在我有点难过了。

非常感谢任何能提供帮助的人

您可以使用继承自 Varien_Data_Collection_Db 超类

的 setOrder() 方法
$cmsPages = Mage::getModel('cms/page')->getCollection()
        ->addStoreFilter(Mage::app()->getStore()->getId())
        ->addFieldToFilter('is_active',1)
        ->addFieldToFilter('identifier', array(
            array(
                'nin' => array(
                        'home',
                        'no-route',
                        'enable-cookies',
                        'thank-you',
                        'home-demo',
                        'empty'
                    )
                )
            )
        )
->setOrder('title','ASC');