How can we add wysiwyg editor in magento custom module?
问问题
1210 次
1 回答
3
1) open file Block_Adminhtml__Edit_Tab_Form
edit field
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('developerpage_form', array('legend'=>Mage::helper('developerpage')->__('Item information')));
/* add below code here */
$configSettings = Mage::getSingleton('cms/wysiwyg_config')->getConfig();
$configSettings['files_browser_window_url'] = $this->getBaseUrl().'admin/cms_wysiwyg_images/index/';
Mage::getSingleton('cms/wysiwyg_config')->setConfig($configSettings);
/* for fieldset add like below */
$fieldset->addField('detail', 'editor', array(
'name' => 'detail',
'label' => Mage::helper('developerpage')->__('Content'),
'title' => Mage::helper('developerpage')->__('Content'),
'style' => 'width:700px; height:500px;',
'config' => $configSettings,
'required' => true,
));
2) open controllers/adminhtml/testcustomercontroller.php find editAction
in editAction find $this->loadLayout(); and paste the below code;
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
}
3) open desing/adminhtml/default/default/yourmodule xml file and add below xml
/* this is my module change with yours */
<developerpage_adminhtml_developerpage_edit>
<update handle="editor" />
</developerpage_adminhtml_developerpage_edit>
NOTE: Dont give field name or id name "content" of editor field nor in Database
Call editor content like below other wise directive would't convert
$_cmsHelper = Mage::helper('cms');
$_process = $_cmsHelper->getBlockTemplateProcessor();
echo $_process->filter(Here your database content);
Now image can be insert. :)
于 2013-03-19T08:56:04.250 回答