내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

How to read the tags title form cq:tags property?

Avatar

이전 커뮤니티 멤버

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.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee

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)

원본 게시물의 솔루션 보기

6 답변 개

Avatar

이전 커뮤니티 멤버

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...

Avatar

정확한 답변 작성자:
Employee

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)

Avatar

이전 커뮤니티 멤버

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?

Avatar

Level 2

Are you talking about tag namespaces? These appear as namespace:tagname (e.g. fruit:apple). Both TagManager and Tag has .getNamespace methods.

Avatar

이전 커뮤니티 멤버

Yes, Tim Donovan....

Avatar

Level 2

Can we read tag title and tag name from a tag selected in dialog directly in sightly?