I'm setting up CKFinder as a file browser for CKEditor and would like the defaultViewType to be different for each Resource Type. For example, when browsing the Images resource it should show thumbnails, but when browsing the Files resource it should display the "compact" view.
I have tried the following configuration, but it just shows thumbnails for both Files and Images:
defaultViewType: "thumbnails",
defaultViewType_Files: "compact"
I had considered writing a small plugin via the onInit function along the following lines:
onInit: function(finder) {
finder.on("folder:getFiles:before", function(event) {
var folder = finder.request("folder:getActive");
var resource = folder.getPath({full: true}).replace(/:.*$/, "");
switch (resource) {
case "Files":
finder.request("files.changeView", "compact");
break;
case "Images":
finder.request("files.changeView", "thumbnails");
break;
});
}
But I'm not sure what request type to fire (files.changeView
or similar doesn't exist).
Is it possible to achieve this either with config options or a plugin?
I'm not sure if you are still interested but this should help you get started:
http://docs.cksource.com/ckfinder3/#!/api/CKFinder.Application-request-settings_setValue
finder.on( 'folder:getFiles:before', function( evt ) {
//console.log(evt.data.folder);
if( evt.data.folder.attributes.resourceType == 'Images' )
finder.request( 'settings:setValue', {
group: 'files',
name: 'viewType',
value: 'thumbnails'
} );
else
finder.request( 'settings:setValue', {
group: 'files',
name: 'viewType',
value: 'list'
} );
}, null, null, 0 );