簡體   English   中英

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

[英]How to add WYSIWYG Editor in Magento system configuration?

我想在Magento系統配置中添加WYSIWYG編輯器。

並且還可以從那里獲得價值的選項。

干杯。

我從這篇文章中找到了答案。 感謝Marius給出了這個答案。

首先在任何布局文件中添加它,以在config部分中加載編輯器:

<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不會被“禁用”。 但如果你可以忽略這一點,你可以毫無問題地使用它。

你需要做的是添加一個WYSIWYG編輯器及其相應的adminhtml控制器。 在此之后,您可以為指定的每個配置字段加載編輯器。

試着閱讀這篇文章 這是如何添加編輯器的分步指南。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM