3

Is there any way to make the Assets folder also show the first sub folder level by default, like in the attached screenshot?

enter image description here

1
  • I would like to see this as well!
    – Anna_MediaGirl
    Oct 16 '17 at 18:43
2

You could modify this JavaScript to do it for you. We currently have it running on a site where this was sought-after

Caveat: Our script opens ALL folders, not just the first level - hence the need to modify.

jQuery(window).on('load', function() {
    var $ = jQuery;

    var openFolders = function() {
        var imageRootLinks = $('a[data-key^="folder:"]');

        $.each(imageRootLinks, function(index, link) {
            var imageRoot = $(link).parent();
            var toggle = imageRoot.find('.toggle');
            if (toggle.length && !imageRoot.hasClass('expanded')) {
                toggle.first().click();
            }
        });
    };

    // open folders in left menu
    openFolders();

    // open folders in image selector
    $(document).ajaxComplete(function(e, status, requestData) {
        if (requestData.url && requestData.url.indexOf('getElements') && requestData.data && requestData.data.indexOf('context=modal&elementType=Asset') != -1) {
            openFolders();  
        }
    });
});

Then simply include the JS-file through a plugin

// runs on all requests
public function init() {
    // check that user is logged in and in the control panel
    if ( craft()->request->isCpRequest() && craft()->userSession->isLoggedIn() ) {
        // the includeJsResource method will add a js file to the bottom of the page
        craft()->templates->includeJsResource('myplugin/js/openFolders.js');
    }

}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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