Extend Asset List, Column, and Card view (for AEM 6.2)
Objective
Each view mode in the Adobe Experience Manager AEM Assets console displays a set of metadata based on the metadata schema associated with the assets.
However, you can display custom metadata in the List, Column, and Card view layouts by configuring existing metadata fields or adding fields using the Metadata Schema editor. The following sections describe how to extend the various layouts to render custom metadata.
Add custom metadata to assets
To add custom metadata prod:brandName, first register the namespace prod. Perform these steps to register the namespace prod:
- Navigate to the CRX explorer http://localhost:4502/crx/explorer, and log in with administrator credentials.
- Browse to the namespace editor page http://localhost:4502/crx/explorer/ui/namespace_editor.jsp
- Click New.
- In the URI box, add the namespace URI http://brand.com/retail/production.
- Click Ok.
- Enter prod in the prefix textbox.
- Click Ok.
- Click Ok to close the conformation dialog.
- Click Apply to save the changes.
Perform these steps to add the custom metadata field prod:brandName using the metadata editor:
- From the Assets console, go to Tools > Assets > Metadata Schemas.
- Select the default form, and click Edit
- Drag the Single Line Text field to the form layout design area.
- Select the text field, and enter the values.
- Specify Brand as the value for Field Label.
- Specify ./jcr:content/metadata/prod:brandName as the value of Map to property.
- Click Done to save the form.
- From the Assets console, select the asset(s), and click View Properties. The metadata editor is displayed for the selected asset(s).
- Specify a value in the custom metadata field, and save the form.
Display custom metadata in Assets List View
- Navigate to CRXDE Lite from the URL http://localhost:4502/crx/de/index.jsp.
- Overlay the node /libs/dam/gui/content/commons/availablecolumns under apps.
- Add a node with the name brand and type nt:unstructured.
- Add the following properties to the node:
- Overlay /libs/dam/gui/coral/components/admin/contentrenderer/row/asset under apps.
- Copy the file jsp from /libs/dam/gui/coral/components/admin/contentrenderer/row/ to /apps/dam/gui/coral/components/admin/contentrenderer/row/asset.
- Edit the file jsp copied under /apps, and include custom.jsp by adding the following statement at line number 60 (before the displayLanguage row):
<cq:include script = “custom.jsp”/>
- Right-click the node /apps/dam/gui/coral/components/admin/contentrenderer/row/asset, and select Create > Create File.
- Add jsp with the following content:
<%@page session=”false”%><%
%><%@page import=”
org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ResourceResolver,
org.apache.sling.api.resource.ResourceUtil”%><%
%><%@taglib prefix=”sling” uri=”http://sling.apache.org/taglibs/sling/1.0″%><%
%><%@taglib prefix=”cq” uri=”http://www.day.com/taglibs/cq/1.0″%><%
%><%@taglib prefix=”ui” uri=”http://www.adobe.com/taglibs/granite/ui/1.0″%><%
%><cq:defineObjects /><%
String metadataPath = resource.getPath() + “/jcr:content/metadata/”;
Resource metadataRes = resourceResolver.getResource(metadataPath);
String brandName = ResourceUtil.getValueMap(metadataRes).get(“prod:brandName”, “”);
%>
<td is=”coral-td” value=”<%= brandName %>”><%= brandName %></td>
- Go to the Assets console, and select the List View The custom metadata field Brand is displayed between the Title and Locale columns.
Display custom metadata in Column View
- Navigate to CRXDE Lite from the URL http://localhost:4502/crx/de/index.jsp.
- Overlay the node /libs/dam/gui/coral/components/admin/contentrenderer/column/columnpreview under apps.
- Copy jsp from /libs/dam/gui/coral/components/admin/contentrenderer/column/columnpreview to /apps/dam/gui/coral/components/admin/contentrenderer/column/columnpreview.
- Edit the file jsp under /apps, and include custom.jsp by adding following statement at line number 132 (before Modified check):
<cq:include script = “custom.jsp”/>
Note: Ensure that you use the closing expression %> appropriately within the scriptlet.
- Include the prefix cq in the header section of jsp:
<%@taglib prefix=”cq” uri=”http://www.day.com/taglibs/cq/1.0″%>
- Right-click the node /apps/dam/gui/coral/components/admin/contentrenderer/column/columnpreview, and select Create > Create File.
- Add the file jsp with the following content:
<%@page session=”false”%><%
%><%@page import=”
org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ResourceResolver,
org.apache.sling.api.resource.ResourceUtil”%><%
%><%@taglib prefix=”sling” uri=”http://sling.apache.org/taglibs/sling/1.0″%><%
%><%@taglib prefix=”cq” uri=”http://www.day.com/taglibs/cq/1.0″%><%
%><%@taglib prefix=”ui” uri=”http://www.adobe.com/taglibs/granite/ui/1.0″%><%
%><cq:defineObjects /><%
String contentPath = slingRequest.getRequestPathInfo().getSuffix();
String metadataPath = contentPath + “/jcr:content/metadata/”;
Resource metadataRes = resourceResolver.getResource(metadataPath);
String brandName = ResourceUtil.getValueMap(metadataRes).get(“prod:brandName”, “”);
%>
<coral-columnView-preview-label>Brand</coral-columnView-preview-label>
<coral-columnview-preview-value><%= xssAPI.encodeForHTML(brandName) %></coral-columnview-preview-value>
- Go to the Assets console, and select Column View
- The custom metadata field Brand is displayed when the asset is selected.
Display custom metadata in Card View
- Navigate to CRXDE Lite from the URL http://localhost:4502/crx/de/index.jsp.
- Overlay the node /libs/dam/gui/coral/components/admin/contentrenderer/card/asset under apps.
- Copy jsp from /libs/dam/gui/coral/components/admin/contentrenderer/card/asset to /apps/dam/gui/coral/components/admin/contentrenderer/card/asset.
- Edit jsp under /apps, and include custom.jsp by adding following statement at line number 46 (before the first property list document):
<cq:include script = “custom.jsp”/>
Note: Ensure that you use the opening (<%) and closing (%>) expressions appropriately within the scriptlet.
- Right-click the node /apps/dam/gui/coral/components/admin/contentrenderer/card/asset, and select Create > Create File.
- Add the file jsp with the following content:
<%@page session=”false”%><%
%><%@page import=”
org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ResourceResolver,
org.apache.sling.api.resource.ResourceUtil”%><%
%><%@taglib prefix=”sling” uri=”http://sling.apache.org/taglibs/sling/1.0″%><%
%><%@taglib prefix=”cq” uri=”http://www.day.com/taglibs/cq/1.0″%><%
%><%@taglib prefix=”ui” uri=”http://www.adobe.com/taglibs/granite/ui/1.0″%><%
%><cq:defineObjects /><%
String contentPath = slingRequest.getRequestPathInfo().getSuffix();
String metadataPath = resource.getPath() + “/jcr:content/metadata/”;
Resource metadataRes = resourceResolver.getResource(metadataPath);
String brandName = ResourceUtil.getValueMap(metadataRes).get(“prod:brandName”, “”);
%>
<coral-card-propertylist>
<coral-card-property title=”Brand”><%= xssAPI.encodeForHTML(brandName) %></coral-card-property>
</coral-card-propertylist>
- From the Assets console, and select the Card View The custom metadata field Brand is displayed on the asset’s card.
Note: The option Overlay Node is available on the toolbar at CRX DE Lite to overlay the node structure under /apps. It is enabled when the node is selected. Ensure you choose /apps as an Overlay Location and enable the Match Node Types option.
The post Render custom metadata for Assets in AEM appeared first on Experience Delivers.