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

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

AEM 6550 - AEM Assets show Tags in List View | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

AEM 6550 - AEM Assets show Tags in List View by Sreekanth Choudry Nalabotu

Abstract

Solution

1) Add the custom tag column 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)







2) Add the following code for rendering tag titles 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" %>
<%@ page import="com.day.cq.tagging.TagManager" %>
<%@ page import="com.day.cq.tagging.Tag" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="com.day.cq.dam.api.Asset" %>
<%@ page import="org.apache.commons.collections.CollectionUtils" %>
<%@ page import="org.apache.commons.lang3.ArrayUtils" %>
<%@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;
TagManager tagManager = assetResource.getResourceResolver().adaptTo(TagManager.class);
String eaemTags = "";

if(assetResource.getResourceType().equals(ASSET_RES_TYPE)){
Object[] tags = (Object[])assetResource.adaptTo(Asset.class).getMetadata("cq:tags");

if(!ArrayUtils.isEmpty(tags)){
List tagWords = new ArrayList(tags.length);

Arrays.stream(tags).forEach(tag -> tagWords.add(tagManager.resolve(tag.toString()).getTitle()));

eaemTags = String.join(", ", tagWords);;
}
}
%>
<%= eaemTags %>




Read Full Blog

AEM 6550 - AEM Assets show Tags in List View

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

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now