Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
tagfn
provides methods to find both content that is tagged and tags applied to content items.These templating functions are provided by the Content Tags module. The java class implementing the methods is .
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]