Hi all,
From one javascript file I am receiving the following array:
tags ["parenttag:tag1/subtag1", "parenttag:tag1/subtag2", "parenttag:tag1/subtag3", "parenttag:tag2/subtag4", "parenttag:tag2/subtag5"]
I would need to get each tag title from these values. E.g from "parenttag:tag1/subtag1" the tag title is defined as "Subtag 1"
Is there any way of doing this from javascript?
Thank you.
Views
Replies
Total Likes
Hi
Let say:
Var a = ["parenttag:tag1/subtag1", "parenttag:tag1/subtag2", "parenttag:tag1/subtag3", "parenttag:tag2/subtag4", "parenttag:tag2/subtag5"];
So ,
a[0] would print :- "parenttag:tag1/subtag1"
a.length := 5
and
Var result = a[0].split("/");
result would be :- ["parenttag:tag1", "subtag1"]
and result[1] would give you:- "subtag1"
Now repeat this in a for loop from 1 to a.length
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi kautuksahni,
thanks for you help but I am afraid that does not work for me, as I could have "parenttag:tag1/subtag1" which its actual title could be "Little Kitties"
Is any CQ object I can call from the front end to get this value? or any other way/workaround to do so?
Views
Replies
Total Likes
AFAIK, there is no OOTB direct way to resolve the tag and get the title in JS
But you might want to look into the code of tagpicker field in TOUCH UI and one option can be a servlet where you can pass Id's in one go and get all title
Thanks
Views
Replies
Total Likes
Trying to read the DOM to get tags information is not best practice.
There are much better ways to get Tag in AEM via the Tag Manager API. See these articles:
Developing a Sightly Component that searches for AEM Content Tags
Using Custom Tag Libraries to search for AEM Content Tag
Hope these help
Views
Replies
Total Likes
you can do like this, it's very simple,
$.ajax({
type: "GET",
url: "/etc/tags/TestTag/"+Tagid+".json", //
success : function(data) {
TagTitle= data["jcr:title"];
}
});
Views
Replies
Total Likes
No, I don't think it's simple.
1. Direct URL could be blocked via dispatcher.
2. By default, Anonymous user does not have tags permission. https://docs.adobe.com/docs/en/aem/6-2/administer/content/tags.html#Setting Tag Permissions
Thanks
Views
Replies
Total Likes
Hi,
Can you please publish the updated links, as the below ones are not available anymore
Developing a Sightly Component that searches for AEM Content Tags
Views
Replies
Total Likes
Views
Replies
Total Likes