2

I would like to add a link to the CMS menu on the Magento Admin panel for the Media Library, just under the polls link.

enter image description here

to link to...

enter image description here

I tried creating a module with the below adminhtml.xml

<config>
    <menu>
        <cms>
            <children>
                <medialink translate="title" module="cms">
                    <title>Media Library</title>
                    <action>adminhtml/cms_wysiwyg_images</action>
                    <sort_order>100</sort_order>
                </medialink>
            </children>
        </cms>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <cms>
                        <children>
                            <medialink translate="title">
                                <title>Media Library</title>
                            </medialink>
                        </children>
                    </cms>
                </children>
            </admin>
        </resources>
    </acl>
</config>

This only succeeds in adding the link to the menu, the <action>adminhtml/cms_wysiwyg_images</action> does not work as I'd hoped. The link directs the user to a broken page, not the proper media library.

enter image description here

UPDATE

Looking more closely at the ajax calls in the browser when you open the media library I see MediabrowserUtility.openDialog is called from /js/mage/adminhtml/browser.js. Although browser.js is not loaded on the dashboard.

3
  • 1
    i think you have to load it via ajax somehow. This would be an awesome addition to magento1! I had to explain so many customers how to just add an image to the media library and it's so over complicated that many customers don't get it. I will look into this when I find the time Commented Mar 21, 2016 at 18:21
  • There's an extension lanot file manager that does pretty much what you ask.
    – ladle3000
    Commented Mar 22, 2016 at 1:04
  • @DavidVerholen, thanks. I had a closer look as to how the media library is being loaded. See my update. Not sure how to add this to a module though
    – Holly
    Commented Mar 22, 2016 at 9:39

1 Answer 1

4

The action you are trying to point to is meant to be called via ajax.
If you take a look at the method Mage_Adminhtml_Cms_Wysiwyg_ImagesController::indexAction() you will find this:

public function indexAction()
{
    $storeId = (int) $this->getRequest()->getParam('store');

    try {
        Mage::helper('cms/wysiwyg_images')->getCurrentPath();
    } catch (Exception $e) {
        $this->_getSession()->addError($e->getMessage());
    }
    $this->_initAction()->loadLayout('overlay_popup');
    $block = $this->getLayout()->getBlock('wysiwyg_images.js');
    if ($block) {
        $block->setStoreId($storeId);
    }
    $this->renderLayout();
}

The line $this->_initAction()->loadLayout('overlay_popup'); means that the default layout handle is not loaded. Instead overly_popup layout handle is loaded. That's why you get the "broken" page.

Maybe you should create a custom controller action that calls the page you need via ajax. This should solve your problem.

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.