Magnolia 6.1 reached end of life on March 31, 2021. This branch is no longer supported, see End-of-life policy.
tagfn
helps you find content by tag. You can also find out what tags are applied to a particular content item. The tagfn
templating functions are provided by the Content Tags module. The Java class that implements the methods is TagTemplatingFunctions.
The method searches content by workspace, root path and a list (array) of tags. Returned content nodes must have at least one of the tags of the given tag array.
Set<ContentMap>
getContentByTags(String workspace, String rootPath, String... tagsArray)
workspace | required The workspace to search in. |
rootPath | required The root path of the node to search in. |
tagsArray | required Any array of tags. |
A Set of ContentMap
objects.
[#assign geniusContacts=tagfn.getContentByTags("contacts", "/", ["genius", "artist"])! /] [#if geniusContacts?has_content] [#list geniusContacts as contact] ${contact.firstName!""} ${contact.lastName!""}[#sep], [/#sep] [/#list] [/#if]
Returns the tags of a given content node.
Set<String> getTags(ContentMap content)
content | required The content map whose tags you want to find. |
A Set of Strings.
[#assign contentItem = cmsfn.contentByPath("/ppicasso", "contacts")! /] [#assign tags = tagfn.getTags(contentItem)! /] [#if tags?has_content] ${contentItem.firstName!""} ${contentItem.lastName!""} has the following tags: [#list tags as tag ] ${tag}[#sep], [/#sep] [/#list] [/#if]