本文介绍了如何获取Magento中的cms页面列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要做什么
我创建了一个管理表单,用户需要从下拉菜单中选择CMS页面.
I have created an admin form where the user needs to select a CMS page from a drop down.
我尝试过的事情
$form->addField('cms_page_id', 'select', array(
'label' => Mage::helper('custom/data')->__('CMS Page'),
'class' => 'required-entry',
'required' => true,
'name' => 'cms_page_id',
'values' => Mage::getSingleton('cms/page')->toOptionArray(),
'value' => $this->getCmsPageId()
));
想法是代码从CMS模型获取一个选项数组.但是,"toOptionArray"对于"cms/page"模型无效.
The idea is the code gets the an option array from the CMS model. However "toOptionArray" is an invalid function for the 'cms/page' model.
我的问题
如何在Magento的管理表单中使用CMS页面的可选数组?
How can I get an option array of CMS pages for use in an admin form in Magento?
推荐答案
使用您的代码,您将加载新的cms页面模型.要获取集合,请使用以下代码,并且toOptionArray()
至少会返回一些内容:
With your code you are loading a new cms page model. To get a collection use following code and toOptionArray()
will at least return something:
Mage::getModel('cms/page')->getCollection()->toOptionArray()
这篇关于如何获取Magento中的cms页面列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!