|
魔扣币兑换比例:【 50以下 : ¥1 = 10 魔扣币 】丨【 50 - 100 :¥1 = 20 魔扣币】丨【 100以上:¥1 = 30 魔扣币 】
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
有时候,我们需要添加自定义属性到一个CMS页面。我会尽力描述我们如何能做到这一点,尽可能简单地使用一个自定义的模块。
首先,你应该创建在应用程序/ etc / modules中的模块注册文件:
- <?xml version="1.0"?>
- <config>
- <modules>
- <Atwix_CMS>
- <active>true</active>
- <codePool>local</codePool>
- </Atwix_CMS>
- </modu
复制代码 在此之后,我们需要创建一个文件夹,它包含我们自己的模块下的app/code/local,在我的情况下,app/code/local/Atwix/CMS。下一步是创建模块的配置文件(app/code/local/Atwix/CMS/etc/config.xml):- <?xml version="1.0"?>
- <config>
- <global>
- <models>
- <atwixcms>
- <class>Atwix_CMS_Model</class>
- </atwixcms>
- </models>
- <events>
- <adminhtml_cms_page_edit_tab_content_prepare_form>
- <observers>
- <atwix_page_edit_tab_content>
- <type>singleton</type>
- <class>Atwix_CMS_Model_Observer</class>
- <method>cmsField</method>
- </atwix_page_edit_tab_content>
- </observers>
- </adminhtml_cms_page_edit_tab_content_prepare_form>
- </events>
- </global>
复制代码 重要提示:我们需要添加一列“content_custom”,“cms_page”表。这可以通过使用Magento的安装脚本,如果你使用Magento企业,你应该添加一列“content_custom”以及“enterprise_cms_page_revision”表。
最后,创建文件(app/code/local/Atwix/CMS/Model/Observer.php):
- <?php
- class Atwix_CMS_Model_Observer
- {
- public function cmsField($observer)
- {
- //get CMS model with data
- $model = Mage::registry('cms_page');
- //get form instance
- $form = $observer->getForm();
- //create new custom fieldset 'atwix_content_fieldset'
- $fieldset = $form->addFieldset('atwix_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()
- ));
复制代码 先描述到这,希望对你有所帮助。
|
|