Quantcast
Channel: Experiencing Adobe Experience Manager (AEM, CQ)
Viewing all articles
Browse latest Browse all 525

AEM 6 - TouchUI Asset Search Select Path Predicate

$
0
0

Goal


Restrict results to assets from certain folder by default when user opens the Search Inner Rail in Touch UI. Projects assets are generally placed in certain root folder (eg. /content/dam/MyProject) and it'd be nice if the search rail by default returns assets from this folder and not entire DAM

Demo | Package Install

Solution


1) Create a Search Facet with Path Predicate

              a. Open Search Facets console  (http://localhost:4502/libs/dam/gui/content/customsearch/searchfacetformlister.html/dam/gui/content/facets) and Edit Assets search facets



              b. Drag and Drop a Path Predicate



              c. Select the project path for path predicate



              d. The predicate shows up in search inner rail




2) The next step is to code a small extension to select path predicate by default when user opens search rail, so that we save author additional 2 clicks each time, for getting the assets results from configured path

          a) Login to CRXDE Lite (http://localhost:4502/crx/de) and create folder /apps/touchui-select-path-predicates

          b) Create node /apps/touchui-select-path-predicates/clientlib of type cq:ClientLibraryFolder and add a String property categories with value dam.admin.search.predicates

          c) Create file (nt:file) /apps/touchui-select-path-predicates/clientlib/js.txt and add

                       select.js

          d) Create file (nt:file) /apps/touchui-select-path-predicates/clientlib/select.js and add the following code.

(function(document, $) {
$(document).ready(function(){
var $path = $("[data-type='path']");

if($path.length == 0){
return;
}

//defined in /libs/dam/gui/content/assets/jcr:content/body/content/aside/items/search
var ASSET_RAIL_SEARCH = "#aem-assets-rail-search";
var $button = $path.find("[role='button']");
var $checkbox = $path.find("input[type='checkbox']");

var doSearch = function(){
$button.click();
$checkbox.click();
};

if($.cookie("endor.innerrail.current") == ASSET_RAIL_SEARCH){
doSearch();
}

$(document).on('click', '.js-endor-innerrail-toggle', function(e) {
doSearch();
});
});
})(document, Granite.$);



Viewing all articles
Browse latest Browse all 525

Trending Articles