Back to Top

wysiwyg editor in Magento Custom Module

Updated 19 May 2017

Magento WYSIWYG Editor

wysiwyg editor in Magento Custom Module : This is very and well known problem for every magento developer . so here is a simple solutions to add the wysiwyg editor in magento module  development .

Step 1 – Go to app/code/local/Webkul/Faq/Block here webkul is namespace and faq is module name , under your _prepareLayout() function add this code


[stextbox id=”info” shadow=”true”]public function _prepareLayout()
{
if (Mage::getSingleton(‘cms/wysiwyg_config’)->isEnabled() && ($block = $this->getLayout()->getBlock(‘head’))) {
$block->setCanLoadTinyMce(true);
}
return parent::_prepareLayout();
}[/stextbox]

Searching for an experienced
Magento Company ?
Find out More

Then go to app/code/local/Webkul/Faq/Block/Adminhtml/Faq/Edit/Tab

and add following code in your _prepareForm() function  below your setform() . $this->setForm($form);

[stextbox id=”info” shadow=”true”]$wysiwygConfig = Mage::getSingleton(‘cms/wysiwyg_config’)->getConfig(array(‘add_variables’ => false, ‘add_widgets’ => false,’files_browser_window_url’=>$this->getBaseUrl().’admin/cms_wysiwyg_images/index/’));[/stextbox]

then define this as $fieldset

[stextbox id=”info” shadow=”true”]$fieldset->addField(‘body’, ‘editor’, array(
          ‘name’      => ‘body’,
          ‘label’     => Mage::helper(‘faq’)->__(‘Content’),
          ‘title’     => Mage::helper(‘faq’)->__(‘Content’),
          ‘style’     => ‘width:700px; height:500px;’,
          ‘state’     => ‘html’,
          ‘config’      => $wysiwygConfig,
          ‘wysiwyg’   => true,
          ‘required’  => true,
      ));[/stextbox]

now go to app/design/adminhtml/default/default/layout and add this xml code
[stextbox id=”info” shadow=”true”]<faq_adminhtml_faq_edit>
       <update handle=”editor”/>
    </faq_adminhtml_faq_edit>[/stextbox]

where first faq is module name and second faq is model name . Bingo you have working wysiwyg editor in magento 🙂

Reindex data from magento after adding this

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


1 comments

  • deepika
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home