Skip to content

Instantly share code, notes, and snippets.

@0-Sony
Last active May 6, 2016 09:05
Show Gist options
  • Save 0-Sony/5bea3d14ad090b8b473a to your computer and use it in GitHub Desktop.
Save 0-Sony/5bea3d14ad090b8b473a to your computer and use it in GitHub Desktop.
Add Wysiwyg To system config Magento
<?php
/** Create a block adminhtml **/
class Namespace_Module_Block_Adminhtml_System_Config_Editor extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
{
/**
* Allowed Wysiwyg
* @return string
*/
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
{
$element->setWysiwyg(true);
$element->setConfig(Mage::getSingleton('cms/wysiwyg_config')->getConfig());
return parent::_getElementHtml($element);
}
}
<!-- Add this in any Layout in design/adminhtml -->
<?xml version="1.0" encoding="utf-8" ?>
<layout version="0.1.0">
<!-- Enabled Wysiyg in system config -->
<adminhtml_system_config_edit>
<!-- Called handle Editor to add Js that wysiwyg need -->
<update handle="editor"/>
<reference name="head">
<action method="setCanLoadTinyMce"><load>1</load></action>
</reference>
</adminhtml_system_config_edit>
</layout>
<config>
<tabs>
<namespace_module translate="label" module="namespace_module">
<label>Tabs Label</label>
<sort_order>100</sort_order>
</namespace_module>
</tabs>
<section>
<namespace_module translate="label" module="namespace_module">
<label>My Custom Label</label>
<tab>namespace_module</tab>
<frontend_type>text</frontend_type>
<sort_order>100</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<groups>
<namespace_group translate="label" module="namespace_module">
<label>Fieldset Label</label>
<frontend_type>text</frontend_type>
<expanded>1</expanded>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<fieldname translate="label" module="namespace_module">
<label>Field label </label>
<frontend_type>editor</frontend_type>
<frontend_model>namespace_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>
</fields>
</namespace_group>
</groups>
</namespace_module>
</section>
</config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment