Want to use Tags to create meta data
I need to write a Pojo class to get the value of cq:tags and then create meta data to get displayed as :
meta Name='tag_name' content='xyz'
I need to write a Pojo class to get the value of cq:tags and then create meta data to get displayed as :
meta Name='tag_name' content='xyz'
Map<String, Object> param = new HashMap<>();
param.put(ResourceResolverFactory.SUBSERVICE, "yourservice");
try (ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(param)) {
Resource res = resolver.getResource("resource path");
ValueMap pageProperties = resource.getValueMap();
String tags = properties.get("cq:tag", String[].class);
TagManager tagManager = resolver.adaptTo(TagManager.class);
List<String> tagValue = new ArrayList<>();
if (Objects.nonNull(tagManager)) {
for (String v : tags) {
Tag tag = tagManager.resolve(v);
if (Objects.nonNull(tag)) {
tagValue.add(tag.getTitle());
}
}
}
iterate over the tagValue in sightly and populate your meta data
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.