1

I'm getting the following Javascript alert when I click the 'browse' button on the image insert popup of the WYSIWYG:

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

event name: open_browser_callback

error message: MediabrowserUtility is not defined

enter image description here

So it looks like mage/adminhtml/browser.js isn't being included which is where MediabrowserUtility is defined.

My Form.php file for this page looks like this:

<?php
class Limesharp_Playzone_Block_Adminhtml_Competition_Edit_Form extends Mage_Adminhtml_Block_Widget_Form{
    protected function _prepareForm(){
        if (Mage::getSingleton('adminhtml/session')->getCompetitionData())
        {
            $data = Mage::getSingleton('adminhtml/session')->getCompetitionData();
            Mage::getSingleton('adminhtml/session')->getCompetitionData(null);
        }
        elseif (Mage::registry('competition_data'))
        {
            $data = Mage::registry('competition_data')->getData();
        }
        else
        {
            $data = array();
        }

        $form = new Varien_Data_Form(array(
                'id' => 'edit_form',
                'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
                'method' => 'post',
                'enctype' => 'multipart/form-data',
        ));

        $form->setUseContainer(true);

        $this->setForm($form);

        $fieldset = $form->addFieldset('competition_form', array(
             'legend' =>Mage::helper('playzone')->__('Competition Details')
        ));

        ...

        $fieldset->addField('details', 'editor', array(
            'label'     => Mage::helper('playzone')->__('Details'),
            'name'      => 'details',
            'config'    => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
            'wysiwyg'   => true
        ));

        $form->setValues($data);

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

What needs to happen for that file to be included?

2 Answers 2

3

It's taken me a few days to crack it but I've finally got it working.

@Marius, got me halfway there, I had to add the collowing to my adminhtml layout file:

<playzone_adminhtml_activity_edit>
    <update handle="editor"/>
    <reference name="head">
         <action method="setCanLoadTinyMce"><load>1</load></action>
    </reference>
</playzone_adminhtml_activity_edit>

While that got rid of the Javascript alert however it loaded a 404 page in the popup.

I had to also edit the WYSIWYG config like so in my Form.php file:

...
$wysiwyg_config = Mage::getSingleton('cms/wysiwyg_config')->getConfig(
            array( 'files_browser_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/cms_wysiwyg_images/index') )
        );

$fieldset->addField('details', 'editor', array(
    'label'     => Mage::helper('playzone')->__('Details'),
    'name'      => 'details',
    'config'    => $wysiwyg_config,
    'wysiwyg'   => true
));
...
1
  • still solving my issues ;) Commented Sep 21, 2016 at 14:02
2

Make sure you have this inside the layout handle for your page:

<layout_handle_here>
    <update handle="editor"/>
    <reference name="head">
         <action method="setCanLoadTinyMce"><load>1</load></action>
         ....
    </reference>
    .....
</layout_handle_here>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.