Hi ,
I have requirement to populate the tags values to drop down in AEM 6.2 and in AEM 5.6.1.
Any suggestions please.
Thanks
Solved! Go to Solution.
What you need to do is using TagManager API - as talked about here:
http://scottsdigitalcommunity.blogspot.ca/2016/06/developing-sightly-component-that.html
You can use custom tag libs too:
http://scottsdigitalcommunity.blogspot.ca/2016/05/using-custom-tag-libraries-to-search.html
Views
Replies
Total Likes
Hi,
Can look into this article:
It can help you.
http://adobeaemclub.com/populate-tags-based-on-selection-in-pathfield-classic-ui/
~ Prince
Views
Replies
Total Likes
Hi Prince,
Thanks for the response.
I guess that one is like populating the cq:tags from the jcr content.I am trying to populate specific section of tags dropdown.
Thanks
Views
Replies
Total Likes
Similiar requirement i have to achieve, please let me know if there is any way ?
Views
Replies
Total Likes
What you need to do is using TagManager API - as talked about here:
http://scottsdigitalcommunity.blogspot.ca/2016/06/developing-sightly-component-that.html
You can use custom tag libs too:
http://scottsdigitalcommunity.blogspot.ca/2016/05/using-custom-tag-libraries-to-search.html
Views
Replies
Total Likes
Adding on top of what scott has mentioned, i would to share with you one article which really help you start developing with TagManager APis
Link:- http://labs.6dglobal.com/blog/2016-09-05/a-primer-on-programmatic-tagging-in-aem/
Link:- http://www.programcreek.com/java-api-examples/index.php?api=com.day.cq.tagging.TagManager
~kautuk
Views
Replies
Total Likes
<dropDownTags cq:showOnCreate="{Boolean}true" jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/autocomplete" allowBulkEdit="{Boolean}true" cq-msm-lockable="cq:tags" emptyText="Add Tags" fieldLabel="Tag" metaType="tags" multiple="{Boolean}true" name="./tag" renderReadOnly="{Boolean}true"> <datasource jcr:primaryType="nt:unstructured" sling:resourceType="datasourceTags"/> <values jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/autocomplete/tags" multiline="{Boolean}true"/> <options jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/autocomplete/list"/></dropDownTags>
Servlet
@SlingServlet(methods = "GET", resourceTypes = "datasourceTags")public class DatasourceTags extends SlingAllMethodsServlet {private static final Logger LOGGER = LoggerFactory.getLogger(DatasourceTheme.class); protected void doGet(SlingHttpServletRequest slingRequest, SlingHttpServletResponse response)throws ServletException, IOException {final ResourceResolver resourceResolver = slingRequest.getResourceResolver(); TagManager tm = resourceResolver.adaptTo(TagManager.class); List<Tag> tags = new ArrayList<Tag>(); String path = ""; if (slingRequest.getRequestParameter("item") != null) { path = slingRequest.getRequestParameter("item").getString(); } else { String referer = slingRequest.getHeader("Referer"); if (StringUtils.isNotEmpty(referer)) { path = referer.substring(referer.indexOf(".html")); } }if (path != null) { String[] parts = path.split("/"); if (resourceResolver.getResource("/etc/tags/tags_theme/" + parts[2]) != null) { Tag pageTags = resourceResolver.getResource("/etc/tags/tags_theme/" + parts[2]).adaptTo(Tag.class); if (pageTags != null) {for (Tag tag : Lists.newArrayList(pageTags.listChildren())) { tags.add(tag); } } } }final Locale locale = slingRequest.getLocale(); final ResourceResolver resolver = resourceResolver; @SuppressWarnings("unchecked") DataSource ds = new SimpleDataSource(new TransformIterator(tags.iterator(), new Transformer() {public Object transform(Object o) { Tag tag = (Tag) o; String tagId = tag.getTagID(); ValueMap vm = new ValueMapDecorator(new HashMap<String, Object>()); vm.put("value", tagId); vm.put("text", tag.getTitle(locale)); return new ValueMapResource(resolver, new ResourceMetadata(), "nt:unstructured", vm); } })); slingRequest.setAttribute(DataSource.class.getName(), ds); } }
Hi, you need to feed a ValueMap thanks to a data source in a servlet that extends SlingAllMethodsServlet then use this datasource as parameter in your _cq_dialog/.content.xml. Don't forget to replace
tags_theme
by your own section name.
Was this usefull ?
Views
Likes
Replies