PageSearch
Extends Search. PageSearch replaces the default Search algorithm with a more specific CMS Page search.
Getting started
PageSearch
is not instantiated automatically, but may be returned from other Page related
methods (such as Page.relatedByTags()
).
You can create a new instance of PageSearch
anywhere within a layout, template or included partial.
In the example below, we're seeking to find 10 descendants of the current Page's top ancestor, excluding itself. It also illustrates how many PageSearch methods may be chained.
<?ev
var pageSearch = new PageSearch();
pageSearch.within(page.topAncestor).exclude(page).limit(10).orderBy('sequence:asc');
for (var result of pageSearch) {
// do something
}
?>
Methods |
---|
childrenOf(Mixed:pages)
PageSearch
Filter search results to immediate children of one or more pages supplied. Pages may be supplied as an Array, PageCollection of Page objects, or an individual Page object.. |
exclude(Mixed:pages)
PageSearch
Excludes one or more pages from the PageSearch.results. The excluded pages may be supplied as an Array, PageCollection of Page objects, or an individual Page object. |
featured()
PageSearch
Restrict results to pages marked as featured. |
orderBy(String:order)
PageSearch
Sets the order and direction of the search. The available order strings for this algorithm are:
|
publishedSince(Mixed:date)
PageSearch
Find Pages published after a given date, which may be supplied as a Date, String or Number timestamp. |
withAuthors(Array:contacts)
PageSearch
Restrict results to those written by one or more Authors. You may supply either a single Contact object, or an Array of Contacts. |
userHasVoted([Boolean:hasVoted])
PageSearch
Restrict results to those the current user has voted up/down. If no current user is available, no results should be returned.
You may also search for pages the user has not voted on (neither up nor down) by supplying |
userHasVotedDown()
PageSearch
Restrict results to those the current user has voted down. If no current user is available, no results should be returned. |
userHasVotedUp()
PageSearch
Restrict results to those the current user has voted up. If no current user is available, no results should be returned. |
withDownVotes()
PageSearch
Restrict results to pages that have one or more down-votes. |
withIds(Array:ids)
PageSearch
Filter search results to an array of known Page IDs. |
within(Page:page)
PageSearch
Find Pages within the descendants of the supplied Page or Array of Pages. |
withTags(Array:tagIds)
PageSearch
Find Pages with one or more Tags, where the Tags are supplied as an Array of Tag system IDs. |
withTagIds(Array:ids [, String:type])
PageSearch
Find Pages with one or more Tag IDs. |
withTagNames(Array:names [, String:type])
PageSearch
Find Pages with one or more Tag names. If no type is supplied then all tag types are searched. |
withTemplate(Template:template)
PageSearch
Find Pages which use the supplied Template. |
withUpVotes()
PageSearch
Restrict results to pages that have one or more up-votes. |
withVotes()
PageSearch
Restrict results to pages that have one or more up-vote/down-vote. |