2013-10-10 114 views

回答

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

現在對於設置frontend_type「編輯」對System.Xml內的元素和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

很好的描述,但對於像我這樣的magento初學者來說很簡短。下載此示例並編輯它作爲Meenakshi說100%的工作解決方案:http://www.junaidbhura.com/add-color-picker-magento-admin-anywhere/ –

+0

好答案@meenakshi –

0

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

嘗試閱讀this article。這是如何添加編輯器的分步指南。

+0

一個鏈接是不是一個答案:請編輯你的答案來描述什麼是必要的步驟,離開鏈接以供參考 – OSdave

+0

@richardbernards以上鍊接引用是爲管理員添加所見即所得編輯器的形式。我想添加在系統配置 –

+0

該系統配置是一個大的管理形式;) – RichardBernards

相關問題