AEM 6520 - AEM Assets add Custom Metadata Columns in Assets Console List View

Goal


Add Custom metadata columns in List view of Assets Consolehttp://localhost:4502/assets.html/

This post adds columns using server side rendering, for adding columns using client side logic check this post

For Custom metadata columns in Search Console check this post

Demo | Package Install | Github


Configure Columns



Columns in List View



Solution


1) Add the custom metadata columns configuration in /apps/dam/gui/content/commons/availablecolumns (Sling Resource Merger combines the otb columns in /libs/dam/gui/content/commons/availablecolumns with ones configured in /apps)

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="nt:unstructured">
    <eaemTitle
        jcr:primaryType="nt:unstructured"
        jcr:title="EAEM Title"
        columnGroup="Experience AEM"
        configurable="{Boolean}true"
        default="{Boolean}true"/>
    <eaemDesc
        jcr:primaryType="nt:unstructured"
        jcr:title="EAEM Description"
        columnGroup="Experience AEM"
        configurable="{Boolean}true"
        default="{Boolean}true"/>
    <eaemKeywords
        jcr:primaryType="nt:unstructured"
        jcr:title="EAEM Keywords"
        columnGroup="Experience AEM"
        configurable="{Boolean}true"
        default="{Boolean}true"/>
</jcr:root>


2) Add the following code for rendering metadata values in /apps/dam/gui/coral/components/admin/contentrenderer/row/common/reorder.jsp; include the otb reorder.jsp using cq:include

<%@include file="/libs/granite/ui/global.jsp"%>
<%@ page import="org.apache.sling.api.resource.ValueMap" %>
<%@ page import="org.apache.sling.api.resource.Resource" %>
<%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0"%>

<%
    final String ASSET_RES_TYPE = "dam/gui/coral/components/admin/contentrenderer/row/asset";

    Resource assetResource = resource;
    String eaemTitle = "", eaemDesc = "", eaemKeywords = "";

    if(assetResource.getResourceType().equals(ASSET_RES_TYPE)){
        ValueMap vm = assetResource.getChild("jcr:content/metadata").getValueMap();

        eaemTitle = (String)vm.get("eaemTitle", "");
        eaemDesc = (String)vm.get("eaemDesc", "");
        eaemKeywords = (String)vm.get("eaemKeywords", "");
    }

%>

<td is="coral-table-cell" value="<%= eaemTitle %>">
    <%= eaemTitle %>
</td>

<td is="coral-table-cell" value="<%= eaemDesc %>">
    <%= eaemDesc %>
</td>

<td is="coral-table-cell" value="<%= eaemKeywords %>">
    <%= eaemKeywords %>
</td>

<cq:include script = "/libs/dam/gui/coral/components/admin/contentrenderer/row/common/reorder.jsp"/>

No comments:

Post a Comment