Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Custom Module - WYSIWYG image browse issue

I have a custom module with a content field (WYSIWYG editor)

When I select the insert image button, the following popup appears. For some reason the 'browse' button at the side of the Image URL has disappeared. Can someone point me in the right direction to get the image icon back? (what block/controller etc)

What is required when adding the full featured WYSIWYG editor to a custom magento module?

No browse icon at side of image url

This is my form field element within Form.php (block)

$fieldset->addField('post_content', 'editor', array(
    'name'      => 'post_content',
    'label'     => Mage::helper('faqs')->__('Answer'),
    'title'     => Mage::helper('faqs')->__('Answer'),
    'style'     => 'width:700px; height:500px;',
    'wysiwyg'   => true,
)); 

Thank you.

Jonny

like image 270
verheesj Avatar asked Feb 20 '23 06:02

verheesj


2 Answers

Had to find out the hard way, but the solution is quite simple:

Please check the permissions of your Role your Admin is in unser System=>Permissions=>Roles

There you can find in the Tab "Role Resources" the Checkbox "Media Gallery". Make sure this checkbox is ticked!

Then, clean cache, log out and in again and it should work.

Cheers!

like image 84
Phil Avatar answered Feb 27 '23 07:02

Phil


I managed to sort this by adding some configuration options to the field,

Add the following code above the addField() of your WYSIWYG,

$configSettings = Mage::getSingleton('cms/wysiwyg_config')->getConfig( 
array( 'add_widgets' => false, 'add_variables' => false, 'add_images' => false,  'files_browser_window_url'=> $this->getBaseUrl().'admin/cms_wysiwyg_images/index/')); 

Once you've added the code, you need to add another param to the addField called 'config' calling your $configSettings variable.

$fieldset->addField('post_content', 'editor', array(
    'name'      => 'post_content',
    'label'     => Mage::helper('faqs')->__('Answer'),
    'title'     => Mage::helper('faqs')->__('Answer'),
    'style'     => 'width:700px; height:500px;',
    'wysiwyg'   => true,
    'config' => $configSettings
)); 
like image 20
verheesj Avatar answered Feb 27 '23 07:02

verheesj