5

我想在 Magento 系统配置中添加所见即所得编辑器。

并且还可以从执行此操作的选项中获取价值。

干杯。

4

2 回答 2

7

我从这篇文章中找到了答案。感谢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 不会被“禁用”。但是,如果您可以忽略这一点,则可以毫无问题地使用它。

于 2014-03-15T06:06:59.677 回答
0

您需要做的是添加一个所见即所得编辑器及其适当的 adminhtml 控制器。在此之后,您可以为您指定的每个配置字段加载编辑器。

尝试阅读这篇文章。它是如何添加编辑器的分步指南。

于 2013-10-10T12:32:52.680 回答