Author tag throgh component and retrive on Page | Community
Skip to main content
Level 4
November 14, 2022
Solved

Author tag throgh component and retrive on Page

  • November 14, 2022
  • 2 replies
  • 1305 views

Hi Team, 

I'm trying to create a component which has the resource type as 

cq/gui/components/coral/common/form/tagfield

I want to retrive this component values on page like text filed. Is there a way to do this. Getting tag values from component not from page properties. 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by salamswapnil

Hi @tessa_learner1 

In your sling model you can use TagManager API to read tag values.

@SlingObject
private ResourceResolver resourceResolver;
@ValueMapValue
private String tagName; //tag field name from your component dialog
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
Tag tag = tagManager.resolve(tagName);
String tagTitle = tag.getTitle();
String tagId = tag.getId(); 

More details on TagManager API can be found in below javadoc.

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/tagging/TagManager.html

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/tagging/Tag.html

 

2 replies

salamswapnilCommunity AdvisorAccepted solution
Community Advisor
November 14, 2022

Hi @tessa_learner1 

In your sling model you can use TagManager API to read tag values.

@SlingObject
private ResourceResolver resourceResolver;
@ValueMapValue
private String tagName; //tag field name from your component dialog
TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
Tag tag = tagManager.resolve(tagName);
String tagTitle = tag.getTitle();
String tagId = tag.getId(); 

More details on TagManager API can be found in below javadoc.

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/tagging/TagManager.html

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/tagging/Tag.html

 

Mani_kumar_
Community Advisor
Community Advisor
November 14, 2022

Do you want to read them from the component and display on the page as text ?

If that is the case which one do you want to display is it tagname or tagId ?

Can you explain more on this ?

Level 4
November 15, 2022

Hi @mani_kumar_ Thanks for your response. Yes I want to read tags through component and I just want to display only the name of the tag on page. 

Mani_kumar_
Community Advisor
Community Advisor
November 15, 2022

Hi @tessa_learner1 

If that is the case as mentioned by @salamswapnil use Tagmanager API read name from the parsed Tag object it should solve your problem.