媒体上传在magento自定义模块编辑器中不起作用 [英] Media upload is not working in magento custom module editor

查看:110
本文介绍了媒体上传在magento自定义模块编辑器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have created a custom module in magento which contains a textbox and an editor. But when I try to upload image or video using editor it is displaying me the error like.

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

event name: open_browser_callback

error message: MediabrowserUtility is not defined

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

Because of this I am unable to upload any image or video in my module.

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

How to solve this problem? Please Help me..

推荐答案

在你的config.xml中你有:

In your config.xml you have:

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

Block / Adminhtml / WHATEVER / Edit.php

In Block/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 /的顶部编辑/ Tab / Form.php

Then in the top of 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。

Standard gotcha: don't call your wysiwyg area 'content'. That is used already by Magento for the form id.

这篇关于媒体上传在magento自定义模块编辑器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆