Add tinyMCE editor in magento custom module
If we have created a custom module using Magento Module creator means, it will not contain 'wysiwyg(tinyMCE)' editor feature.
We can add the 'wysiwyg' editor in custom module within 2 steps.
Step 1:
Add the following code in
Note: Field name should not be 'content' if you keep your field as 'content'(which is already available), editor will be shown all over the admin content block. So give some other name for content filed.
We can add the 'wysiwyg' editor in custom module within 2 steps.
Step 1:
Add the following code in
/controllers/Adminhtml/BlogController.php
under the line $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
.if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {Step 2:Add the following code in
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
}
/Block/Adminhtml/Blog/Edit/Tab/Form.php
file, within your field declaration.'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),Now, it will look like this
That's it! We have added tinyMCE editor in our magento custom module:)
$fieldset->addField('post_content', 'editor', array(
'name' => 'post_content',
'label' => Mage::helper('blog')->__('Content'),
'title' => Mage::helper('blog')->__('Content'),
'style' => 'width:900px; height:500px;',
'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
'wysiwyg' => true,
'required' => true,
));
Note: Field name should not be 'content' if you keep your field as 'content'(which is already available), editor will be shown all over the admin content block. So give some other name for content filed.
Hi, thanks for the tutorial, one problem I've encountered is that after following this guide the whole form is placed within the wysiwyg editor rather than just applying the editor to the specified field.
ReplyDeleteAny advice?
I fixed it, it was the issue with the field name being called 'content' Sorry to waste your time :)
ReplyDeleteNo problem you have fixed your self ;) Thanks for commenting:)
ReplyDeleteshow/hide editor button is display, but editor not display.
ReplyDeleteDhara try it once again after clearing cache. Please make sure that you have followed those 2 steps correctly! It's worked perfectly for me. The only problem in this code is i couldn't not able to insert image using image widget. This post having step-by-step screenshot http://www.magentocommerce.com/boards/error.php/viewthread/77009/#t218074 feel free to follow that :)
ReplyDeleteSame issue with me. I am only geting show/hide editor button, i cleared the cache, and followed the steps but no luck, early help is appriciated
ReplyDeleteHi Pankaj, please follow the above sangam's replay link. It's helped me to get the widget with full functionality as like in CMS module.
ReplyDelete