Hey Everyone,
I just wanted to share something regarding ordering the AEM Tags under Tagging console (Touch UI) in ascending order.
There isn't any OOTB way to do it. However, I tried something and it worked. The solution may not be the most optimal one, but it works.
-------------
Steps to Do:
-------------
1) Overlay /libs/cq/tagging/gui/components/admin/endor/datasources/tagsdatasource/tagsdatasource.jsp
in /apps/cq/tagging/gui/components/admin/endor/datasources/tagsdatasource/tagsdatasource.jsp and then make the changes to the apps' tagsdatasource.jsp file accordingly.
2) Code Sample: Added the lines that have comments on their right.
---------------------------------------------------------------------------------------------
TagManager tagMgr = resourceResolver.adaptTo(TagManager.class);
String suffix = slingRequest.getRequestPathInfo().getSuffix();
Iterator<Tag> it;
List<Tag> listTag = new ArrayList<Tag>(); // Initializing a new List of type Tag.
if (suffix == null) {
it = tagMgr.getNamespacesIter();
} else {
Tag tag = tagMgr.resolve(suffix);
if (tag == null) {
return;
}
it = tag.listChildren();
while (it.hasNext()){ // Adding all the values from the iterator to the list
listTag.add(it.next());
}
listTag.sort((l1,l2)-> l1.getTitle().compareTo(l2.getTitle())); // Sorting the list in ascending order of the title.
it = listTag.iterator(); // Returning the iterator of the sorted list
}
Config cfg = new Config(resource);
Config dsCfg = new Config(resource.getChild(Config.DATASOURCE));
String filters[] = dsCfg.get("filters", String[].class);
---------------------------
---------------------------
Once you make the changes, please recompile JSPs & rebuild clientlibs [1] (via file system) , if the changes don't get reflected.
You should get all the tags in ascending order.
You can also refer to [2] for Tag API documentation:
Hope it works the same way for you too !!
[1] https://helpx.adobe.com/ca/experience-manager/kb/How-to-force-a-recompilation-of-all-Sling-scripts-j...
[2] https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/javadoc/co...
Tags sorted in Ascending Order in AEM 6.4.6