1

我在 magento 中创建了一个自定义模块,其中包含一个文本框和一个编辑器。但是当我尝试使用编辑器上传图像或视频时,它会向我显示类似的错误。

error: error in [unknown object].fireEvent():

event name: open_browser_callback

error message: MediabrowserUtility is not defined

因此,我无法在我的模块中上传任何图像或视频。

如何解决这个问题呢?请帮我..

4

1 回答 1

2

在您的 config.xml 中,您有:

<events>
  <cms_wysiwyg_config_prepare>
    <observers>
      <variable_observer>
        <class>core/variable_observer</class>
        <method>prepareWysiwygPluginConfig</method>
      </variable_observer>
    </observers>
  </cms_wysiwyg_config_prepare>
</events>

在块/Adminhtml/WHATEVER/Edit.php

protected function _prepareLayout() {
    parent::_prepareLayout();
    if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
        $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
        $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
    }
}

然后在 Block/Adminhtml/WHATEVER/Edit/Tab/Form.php 的顶部

     protected function _prepareForm() {
            $form = new Varien_Data_Form();
            $this->setForm($form);
            $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false,
         'add_widgets' => false,
          'add_images' => true,
          'files_browser_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg_images/index'),
          'files_browser_window_width' => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_width'),
          'files_browser_window_height'=> (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_height')
         ));

再向下:

            $fieldset->addField('not-called-content', 'editor', array(
                                    'name'      => 'not-called-content',
                                    'label'     => Mage::helper('WHATEVER')->__('Content'),
                                    'title'     => Mage::helper('WHATEVER')->__('Content'),
                                    'style'     => 'width:550px; height:300px;',
                                    'required'  => false,
                                    'config'    => $wysiwygConfig,
                                    'wysiwyg'   => true
                                    ));

标准陷阱:不要将您所见即所得的区域称为“内容”。Magento 已经将其用于表单 ID。

于 2012-08-31T11:14:07.683 回答