


Hi All,
I need to to display tag title on the jsp page. But, I have read tagID from cq:tags property. My question is " How to read Tag title by using tag ID". Please provide code snippet. That would be helpful.
I have followed this code. Please resolve it.
<%String[] tags = campaignProperties.get("cq:tags", new String[0]);
for(String tag : tags){ %>
<% String tagNameSpace = tag;
ResourceResolver resolver = slingRequest.getResourceResolver();
Resource nameSpaceResource = resolver.getResource(tagNameSpace);
Tag tagTitle = nameSpaceResource.adaptTo(Tag.class);
String tagStr = tagTitle.getTitle(); %>
<h5><%= tagStr.getTitle()%></h5>
Thanks in advance.
You can resolve a Tag via the TagManager (https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/tagging/TagManager.html)
You can do resourceResolver.adaptTo(TagManager.class)
Views
Replies
Sign in to like this content
Total Likes
Hi All,
I resolved it with little bit code changes. Please refer it.
<%String[] tagsNameSpace = pathProperties.get("cq:tags", new String[0]);
for(String tagValue : tagsNameSpace){ %>
<% String tagID = tagValue;
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
Tag tag = tagManager.resolve(tagID); %>
<h5><i><%= tag.getTitle()%> </i></h5><br/>
<% } %>
Thank you all...
You can resolve a Tag via the TagManager (https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/tagging/TagManager.html)
You can do resourceResolver.adaptTo(TagManager.class)
Views
Replies
Sign in to like this content
Total Likes
Hi Feike Visser,
I have resolved it. Right now I need another requirement. After modified code I got all tag titles. But I need that tag titles for each category. Suppose, I read tags titles for Alerts,Audits,DashBoards. So how to separate those tags for related category?
Views
Replies
Total Likes
Are you talking about tag namespaces? These appear as namespace:tagname (e.g. fruit:apple). Both TagManager and Tag has .getNamespace methods.
Views
Replies
Sign in to like this content
Total Likes
Yes, Tim Donovan....
Views
Replies
Total Likes
Can we read tag title and tag name from a tag selected in dialog directly in sightly?
Views
Replies
Sign in to like this content
Total Likes