Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AEM 6560 - Sites Editor Asset Finder set Default Folder | AEM Community Blog Seeding

kautuk_sahni
Community Manager
Community Manager

BlogImage.jpg

AEM 6560 - Sites Editor Asset Finder set Default Folder by Sreekanth Choudry Nalabotu

Abstract

Goal
Sites pages loaded for editing show the assets in /content/dam root by default. This post is for setting the path to a specific project folder...

Solution

1) Add a client library to add editor hook. Login to CRXDE Lite (http://localhost:4502/crx/de), create folder /apps/eaem-asset-finder-default-folder


2) Create node /apps/eaem-asset-finder-default-folder/clientlib of type cq:ClientLibraryFolder, add String[] property categories with value [cq.authoring.editor.hook.assetfinder], String[] property dependencies with value lodash.


3) Create file (nt:file) /apps/eaem-asset-finder-default-folder/clientlib/js.txt, add

default-folder.js

4) Create file (nt:file) /apps/eaem-asset-finder-default-folder/clientlib/default-folder.js, add the following code

(function ($, $document, author) {
var self = {},
IMAGES_FINDER = "Images",
PATH_FIELD = "foundation-autocomplete[name='assetfilter_image_path']",
DEFAULT_FOLDER = '/content/dam/we-retail';

var searchPath = self.searchRoot,
imageServlet = '/bin/wcm/contentfinder/asset/view.html',
itemResourceType = 'cq/gui/components/authoring/assetfinder/asset';

self.loadAssets = function (query, lowerLimit, upperLimit) {
if(_.isEmpty(searchPath)){
searchPath = DEFAULT_FOLDER;
$(PATH_FIELD)[0]._input.value = DEFAULT_FOLDER;
}

var param = {
'_dc': new Date().getTime(),
'query': query.concat("order:\"-jcr:content/jcr:lastModified\" "),
'mimeType': 'image',
'itemResourceType': itemResourceType,
'limit': lowerLimit + ".." + upperLimit,
'_charset_': 'utf-8'
};

return $.ajax({
type: 'GET',
dataType: 'html',
url: Granite.HTTP.externalize(imageServlet) + searchPath,
data: param
});
};

self.setSearchPath = function (spath) {
searchPath = spath;
};

author.ui.assetFinder.register(IMAGES_FINDER, self);
}(jQuery, jQuery(document), Granite.author));

Read Full Blog

AEM 6560 - Sites Editor Asset Finder set Default Folder

Q&A

Please use this thread to ask the related questions.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

0 Replies