我正嘗試使用this指南向Magento CMS頁面編輯器添加自定義字段,但我無法獲取要在後端顯示的其他字段。嘗試將自定義字段添加到Magento頁面CMS
這裏是我所創建的文件:在/ app/etc/modules中
<config>
<modules>
<ddog_customcms>
<active>true</active>
<codePool>local</codePool>
<depends/>
</ddog_customcms>
</modules>
</config>
config.xml文件在/ app /代碼
ddog_customcms.xml /本地/ ddog/customcms/etc
<?xml version="1.0"?>
<config>
<modules>
<ddog_customcms>
<version>1.0.0</version>
</ddog_customcms>
</modules>
<global>
<models>
<ddog_customcms>
<class>ddog_customcms_Model</class>
</ddog_customcms>
</models>
<events>
<adminhtml_cms_page_edit_tab_content_prepare_form>
<observers>
<ddog_customcms_page_edit_tab_content>
<type>singleton</type>
<class>ddog_customcms_Model_Observer</class>
<method>cmsField</method>
</ddog_customcms_page_edit_tab_content>
</observers>
</adminhtml_cms_page_edit_tab_content_prepare_form>
</events>
<resources>
<ddog_customcms_setup>
<setup>
<module>ddog_customcms</module>
</setup>
</ddog_customcms_setup>
</resources>
</global>
</config>
content_custom列添加到cms_page數據庫表
observer.php在/ app /代碼/本地/ ddog/customcms /型號/
<?php
class ddog_customcms_observer
{
public function addNewCmsField($observer)
{
//get CMS model with data
$model = Mage::registry('cms_page');
//get form instance
$form = $observer->getForm();
//create new custom fieldset 'ddog_customcms_content_fieldset'
$fieldset = $form->addFieldset('ddog_customcms_content_fieldset', array('legend'=>Mage::helper('cms')->__('Custom'),'class'=>'fieldset-wide'));
//add new field
$fieldset->addField('content_custom', 'text', array(
'name' => 'content_custom',
'label' => Mage::helper('cms')->__('Content Custom'),
'title' => Mage::helper('cms')->__('Content Custom'),
'disabled' => false,
//set field value
'value' => $model->getContentCustom()
));
}
}
我已清除緩存,但我不能讓該字段出現在頁面編輯器的任何地方。任何人都可以幫忙嗎?
看看這個答案:https://開頭的Magento .stackexchange.com/a/53094 – Rushikumar
感謝您的答覆,但我已經看過答案並嘗試了一些步驟,但仍然沒有運氣。 –