Module error message: MediabrowserUtility is not defined

If you install a custom module in Magento it could lack the TinyMce Mediabrowser. You get the following message then:

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

event name: open_browser_callback

error message: MediabrowserUtility is not defined

How to fix this?

Quick fix

In /app/design/adminhtml/default/default/layout/YOURMODULE.xml add:


            1
            
            
            
            
            
            
            
            js_cssprototype/windows/themes/default.css
            js_cssprototype/windows/themes/magento.css
            lib/prototype/windows/themes/magento.css
            
        

Or change to

Long solution (may not work)

In your /YOURMODULE/etc/config.xml you have:

 
  <cms_wysiwyg_config_prepare>

      <variable_observer>
        core/variable_observer
        prepareWysiwygPluginConfig

In Block/Adminhtml/YOURMODULE/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);
    }
}

Then in the top of Block/Adminhtml/YOURMODULE/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')
         ));

Further down:

$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
                                    ));

With thanks to Theodores

1 thought on “Module error message: MediabrowserUtility is not defined”

  1. Thank you very much for this. I’ve had to reference this more than once now and it has helped save me hours of frustration every time.

Leave a Comment

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

en_USEnglish
Scroll to Top