如何在Magento系统配置中添加WYSIWYG Editor?

Mee*_*m R 5 wysiwyg magento system-configuration magento-1.7

我想在Magento系统配置中添加WYSIWYG编辑器.

并且还可以从中获取值来执行此操作.

干杯.

Mee*_*m R 7

我从这篇文章中找到了答案.感谢Marius给出了这个答案.

首先在任何布局文件中添加它,以在config部分中加载编辑器:

<adminhtml_system_config_edit>
    <update handle="editor"/>
    <reference name="head">
        <action method="setCanLoadTinyMce"><load>1</load></action>
    </reference>
</adminhtml_system_config_edit>
Run Code Online (Sandbox Code Playgroud)

现在创建自己的字段渲染器.它必须是模块内的一个块:

<?php
class Namespace_Module_Block_Adminhtml_System_Config_Editor extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface{
    protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element){
        $element->setWysiwyg(true);
        $element->setConfig(Mage::getSingleton('cms/wysiwyg_config')->getConfig());
        return parent::_getElementHtml($element);
    }
}
Run Code Online (Sandbox Code Playgroud)

现在为system.xml中的元素设置frontend_type'editor'和frontend_model你的新块

<fieldname translate="label">
    <label>Field label </label>
    <frontend_type>editor</frontend_type>
    <frontend_model>module/adminhtml_system_config_editor</frontend_model>
    <sort_order>150</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</fieldname>
Run Code Online (Sandbox Code Playgroud)

将配置范围更改为网站或商店视图时存在一些问题.textarea不会被"禁用".但如果你可以忽略这一点,你可以毫无问题地使用它.