Expand my Community achievements bar.

SOLVED

AEM 6 - Get List of Tags

Avatar

Level 5

I'm trying to get a list of tags available but I keep ending up with an Array of 0

Example code:

        private List<String> tagsList = new ArrayList<String>();

 

        try{
            ResourceResolver resourceResolver = getRequest().getResourceResolver();
            // Session session = resourceResolver.adaptTo(Session.class);
            TagManager tagManager = resourceResolver.adaptTo(TagManager.class);
            Resource resource = resourceResolver.getResource("/etc/tags/bmi");
            Tag[] pageTags = tagManager.getTags(resource);
 
            for(Tag tag : pageTags){
                tagsList.add(tag.getTitle());
            }
        } catch(Exception e) {
            LOG.error("Error getting tags",e);
            throw new ServletException(e);
        }

All the tags live under /etc/tags/bmi.  I'm not sure why I'm not seeing an Array of Tags being returned.

Any help is greatly appreciated.

Thanks,

-Dean

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi 

Please have a look at documentation for some help:-

Link:- https://docs.adobe.com/docs/en/aem/6-1/develop/tags/building.html

//Building Tagging into an AEM Application

 

Link:- https://helpx.adobe.com/experience-manager/using/tagmanager.html

// Using of Tagmanager API

 

Link:- http://experience-aem.blogspot.in/2013/11/aem-cq-56-new-tag-tree-tab-in-sidekick.html

// To add new tags or remove tags for a page, multiple clicks are involved in openingSidekick -> Page Tab -> Page Properties -> Basic -> Tags

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

View solution in original post

1 Reply

Avatar

Correct answer by
Administrator

Hi 

Please have a look at documentation for some help:-

Link:- https://docs.adobe.com/docs/en/aem/6-1/develop/tags/building.html

//Building Tagging into an AEM Application

 

Link:- https://helpx.adobe.com/experience-manager/using/tagmanager.html

// Using of Tagmanager API

 

Link:- http://experience-aem.blogspot.in/2013/11/aem-cq-56-new-tag-tree-tab-in-sidekick.html

// To add new tags or remove tags for a page, multiple clicks are involved in openingSidekick -> Page Tab -> Page Properties -> Basic -> Tags

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni