扩展资产搜索 extending-assets-search
您可以扩展 Adobe Experience Manager Assets 搜索功能。 开箱即用, Experience Manager Assets 按字符串搜索资源。
搜索通过QueryBuilder界面完成,因此可以使用多个谓词自定义搜索。 您可以在以下目录中覆盖缺省谓词集: /apps/dam/content/search/searchpanel/facets
.
您还可以将其他选项卡添加到 Assets 管理面板。
叠加 overlaying
要覆盖预配置的谓词,请复制 facets
节点来源 /libs/dam/content/search/searchpanel
到 /apps/dam/content/search/searchpanel/
或指定其他 facetURL
中的属性 searchpanel
配置(默认为 /libs/dam/content/search/searchpanel/facets.overlay.infinity.json
)。
/apps
不存在,因此请创建它。 确保节点类型与以下节点类型匹配 /libs
.添加选项卡 adding-tabs
您可以通过在以下位置配置其他搜索选项卡: Assets 管理界面。 要创建其他选项卡,请执行以下操作:
-
创建文件夹结构
/apps/wcm/core/content/damadmin/tabs,
如果该文件尚不存在,请复制tabs
节点来源/libs/wcm/core/content/damadmin
然后粘上。 -
根据需要创建和配置第二个选项卡。
note note NOTE 当您创建第二个 siteadminsearchpanel
,请务必设置id
属性以防止表单冲突。
创建自定义谓词 creating-custom-predicates
Assets 附带一组预定义谓词,可用于自定义资产共享页面。 中介绍了如何通过此方式自定义资产共享 创建和配置资产共享页面.
除了使用预先存在的谓词之外, Experience Manager 开发人员还可以使用创建自己的谓词 查询生成器API.
创建自定义谓词需要具备有关 构件框架.
最佳实践是复制并调整现有谓词。 示例谓词位于 /libs/cq/search/components/predicates.
示例:构建简单属性谓词 example-build-a-simple-property-predicate
要构建属性谓词,请执行以下操作:
-
在项目目录中创建组件文件夹,例如, /apps/weretail/components/titlepredicate.
-
添加 content.xml:
code language-xml <?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="https://sling.apache.org/jcr/sling/1.0" xmlns:cq="https://www.day.com/jcr/cq/1.0" xmlns:jcr="https://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Component" jcr:title="Title Predicate" sling:resourceSuperType="foundation/components/parbase" allowedParents="[*/parsys]" componentGroup="Search"/>
-
添加
titlepredicate.jsp
.code language-java <%-- Sample title predicate component --%><%@ page import="java.util.Calendar" %><% %><%@include file="/libs/foundation/global.jsp"%><% // A unique id is necessary in case this predicate is inserted multiple times on the same page String elemId = "cq-predicate-" + Long.toString(Calendar.getInstance().getTimeInMillis()); %><div class="predicatebox"> <div class="title">Title</div> <%-- The wrapper for the form elements. All items are appended to this wrapper. --%> <div id="<%= elemId %>" class="content"></div> </div><script type="text/javascript"> CQ.Ext.onLoad(function() { var predicateName = "property"; var propertyName = "jcr:content/metadata/dc:title"; var elemId = "<%= elemId %>"; // Get the page wide available QueryBuilder. var qb = CQ.search.Util.getQueryBuilder(); // createId adds a counter to the predicate name - useful in case this predicate // is inserted multiple times on the same page. var id = qb.createId(predicateName); // Hidden field that defines the property to search for; in our case this // is the "dc:title" metadata. The name "property" (or "1_property", "2_property", and so on.) // indicates the server to use the property predicate // (com.day.cq.search.eval.JcrPropertyPredicateEvaluator). qb.addField({ "xtype": "hidden", "renderTo": elemId, "name": id, "value": propertyName }); // The visible text field. The name has to be like the one of the hidden field above // plus the ".value" suffix. qb.addField({ "xtype": "textfield", "renderTo": elemId, "name": id + ".value" }); // Depending on the predicate, additional parameters let you configure the // predicate. Here we add an operation parameter to create a "like" query. // Again note the name set to the id and a suffix. qb.addField({ "xtype": "hidden", "renderTo": elemId, "name": id + ".operation", "value": "like" }); }); </script>
-
为了使组件可用,您需要能够对其进行编辑。要使组件可编辑,请在 CRXDE 中添加主类型 cq:EditConfig 的 cq:editConfig 节点。为了删除段落,请添加带有单个值 DELETE 的多值属性 cq:actions。
-
导航到浏览器,并在示例页面中导航(例如, press.html)切换到设计模式并为谓词段落系统启用新组件(例如, 左侧)。
-
在 编辑 模式,新组件现在可在sidekick中使用(可在 Search 组)。 将组件插入到 谓词 列并键入搜索词,例如, 菱形 单击放大镜开始搜索。
note note NOTE 搜索时,请确保键入正确的术语,包括正确的大小写。
示例:构建简单的组谓词 example-build-a-simple-group-predicate
要构建组谓词,请执行以下操作:
-
在项目目录中创建组件文件夹,例如, /apps/weretail/components/picspredicate.
-
添加 content.xml:
code language-xml <?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="https://sling.apache.org/jcr/sling/1.0" xmlns:cq="https://www.day.com/jcr/cq/1.0" xmlns:jcr="https://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Component" jcr:title="Image Formats" sling:resourceSuperType="foundation/components/parbase" allowedParents="[*/parsys]" componentGroup="Search"/>
-
添加 titlepredicate.jsp:
code language-java <%-- Sample group predicate component --%><%@ page import="java.util.Calendar" %><% %><%@include file="/libs/foundation/global.jsp"%><% // A unique id is necessary in case this predicate is inserted multiple times on the same page. String elemId = "cq-predicate-" + Long.toString(Calendar.getInstance().getTimeInMillis()); %><div class="predicatebox"> <div class="title">Image Formats</div> <%-- The wrapper for the form elements. All items are append to this wrapper. --%> <div id="<%= elemId %>" class="content"></div> </div><script type="text/javascript"> CQ.Ext.onLoad(function() { var predicateName = "property"; var propertyName = "jcr:content/metadata/dc:format"; var elemId = "<%= elemId %>"; // Get the page wide available QueryBuilder. var qb = CQ.search.Util.getQueryBuilder(); // Create a unique group ID; will return for example, "1_group". var groupId = qb.createGroupId(); // Hidden field that defines the property to search for - in our case "dc:format" - // and declares the group of predicates. "property" in the name ("1_group.property") // indicates to the server to use the "property predicate" // (com.day.cq.search.eval.JcrPropertyPredicateEvaluator). qb.addField({ "xtype": "hidden", "renderTo": "<%= elemId %>", "name": groupId + "." + predicateName, // 1_group.property "value": propertyName }); // Declare to combine the multiple values using OR. qb.add(new CQ.Ext.form.Hidden({ "name": groupId + ".p.or", // 1_group.p.or "value": "true" })); // The options var options = [ { "label":"JPEG", "value":"image/jpeg"}, { "label":"PNG", "value":"image/png" }, { "label":"GIF", "value":"image/gif" } ]; // Build a checkbox for each option. for (var i = 0; i < options.length; i++) { qb.addField({ "xtype": "checkbox", "renderTo": "<%= elemId %>", // 1_group.property.0_value, 1_group.property.1_value, and so on. "name": groupId + "." + predicateName + "." + i + "_value", "inputValue": options[i].value, "boxLabel": options[i].label, "listeners": { "check": function() { // Submit the search form when checking/unchecking a checkbox. qb.submit(); } } }); } });
-
为了使组件可用,您需要能够对其进行编辑。要使组件可编辑,请在 CRXDE 中添加主类型 cq:EditConfig 的 cq:editConfig 节点。为了删除段落,请添加带有单个值 DELETE 的多值属性 cq:actions。
-
导航到浏览器,并在示例页面中导航(例如, press.html)切换到设计模式并为谓词段落系统启用新组件(例如, 左侧)。
-
在 编辑 模式,新组件现在可在sidekick中使用(可在 Search 组)。 将组件插入到 谓词 列。
已安装的谓词小组件 installed-predicate-widgets
以下谓词可用作预配置的ExtJS小组件。
全文谓词 fulltextpredicate
fulltext
keyup
. 默认为 CQ.wcm.SiteAdmin.doSearch
属性谓词 propertypredicate
property
jcr:title
路径谓词 pathpredicate
path
/content/dam
folder
search in subfolders
. 默认为true。DatePredicate datepredicate
daterange
jcr:content/jcr:lastModified
选项谓词 optionspredicate
daterange
jcr:content/metadata/cq:tags
level1
CQ.wcm.SiteAdmin.doSearch
自定义搜索结果 customizing-search-results
资产共享页面上搜索结果的显示受所选镜头控制。 Experience Manager Assets 附带一组预定义镜头,可用于自定义资产共享页面。 中介绍了如何通过此方式自定义资产共享 创建和配置资产共享页面.
除了使用预先存在的镜片外, Experience Manager 开发者也可以自己制作镜头。