@Singleton public class SearchTemplatingFunctions extends Object
ContentMap
which is more easily accessible in template scripts via . (dot) notation.
Results are sorted by jcr:score() descending. An excerpt from the text containing the query term might be available, depending on the Jackrabbit search configuration.
Read permissions for the current user are checked before adding the result to the collection returned.
Functions are exposed as searchfn
.
Here follows a couple of sample usages.
[#assign searchResults = searchfn.searchPages('foo', '/somepath') /] [#if searchResults?has_content] [#list searchResults as item] <a href="${cmsfn.link(item)}"> <h4>${item.title!}</h4> <p>${item.excerpt!}</p> </a> [/#list] [/#if]and
[#assign searchResults = searchfn.searchContent('myworkspace', 'foo', '/somepath','qux:baz') /] [#if searchResults?has_content] [#list searchResults as item] <a href="${cmsfn.link(item)}"> <h4>${item.title!}</h4> <p>${item.excerpt!}</p> </a> [/#list] [/#if]
Constructor and Description |
---|
SearchTemplatingFunctions() |
Modifier and Type | Method and Description |
---|---|
Collection<info.magnolia.jcr.util.ContentMap> |
searchContent(String workspace,
String queryString,
String startPath,
String returnItemType)
Searches content in any workspace.
|
Collection<info.magnolia.jcr.util.ContentMap> |
searchContent(String workspace,
String queryString,
String startPath,
String returnItemType,
long limit,
long offset)
Searches content in any workspace.
|
Collection<info.magnolia.jcr.util.ContentMap> |
searchPages(String queryString,
String startPath)
Searches the
RepositoryConstants.WEBSITE for NodeTypes.Page#NAME . |
Collection<info.magnolia.jcr.util.ContentMap> |
searchPages(String queryString,
String startPath,
long limit,
long offset)
Searches the
RepositoryConstants.WEBSITE for NodeTypes.Page#NAME . |
public Collection<info.magnolia.jcr.util.ContentMap> searchPages(String queryString, String startPath) throws javax.jcr.RepositoryException
RepositoryConstants.WEBSITE
for NodeTypes.Page#NAME
.javax.jcr.RepositoryException
searchPages(String, String, long, long)
public Collection<info.magnolia.jcr.util.ContentMap> searchPages(String queryString, String startPath, long limit, long offset) throws javax.jcr.RepositoryException
RepositoryConstants.WEBSITE
for NodeTypes.Page#NAME
.javax.jcr.RepositoryException
searchContent(String, String, String, String, long, long)
public Collection<info.magnolia.jcr.util.ContentMap> searchContent(String workspace, String queryString, String startPath, String returnItemType) throws javax.jcr.RepositoryException
returnItemType
- if not specified, defaults to nt:basejavax.jcr.RepositoryException
searchContent(String, String, String, String, long, long)
public Collection<info.magnolia.jcr.util.ContentMap> searchContent(String workspace, String queryString, String startPath, String returnItemType, long limit, long offset) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
searchContent(String, String, String, String)
Copyright © 2017 Magnolia International Ltd.. All rights reserved.