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

时间:2013-10-10 12:18:29

标签: magento magento-1.7 wysiwyg system-configuration

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

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

干杯。

2 个答案:

答案 0 :(得分:7)

我找到了post的答案。感谢Marius给出了这个答案。

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

<adminhtml_system_config_edit>
    <update handle="editor"/>
    <reference name="head">
        <action method="setCanLoadTinyMce"><load>1</load></action>
    </reference>
</adminhtml_system_config_edit>

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

<?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);
    }
}

现在,对于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>

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

答案 1 :(得分:0)

您需要做的是添加一个WYSIWYG编辑器及其相应的adminhtml控制器。在此之后,您可以为您指定的每个配置字段加载编辑器。

尝试阅读this article。这是如何添加编辑器的分步指南。

相关问题