PageSearch

Extends Search. PageSearch replaces the default Search algorithm with a more specific CMS Page search.

Methods
exclude(Mixed:pages)

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.

Returns the original Search object allowing for method chaining.

orderBy(String:order)

Sets the order and direction of the search. The available order strings for this algorithm are:

  • created:asc
  • created:desc
  • modified:asc
  • modified:desc
  • published:asc
  • published:desc
  • sequence:asc
  • sequence:desc
  • title:asc
  • title:desc

Returns the original Search object allowing for method chaining.

within(Page:page)

Find Pages within the descendants of the supplied Page.

Returns the original Search object allowing for method chaining.

withTags(Array:tagIds)

Find Pages with one or more Tags, where the Tags are supplied as an Array of Tag system IDs.

Returns the original Search object allowing for method chaining.

withTemplate(Template:template)

Find Pages which use the supplied Template.

Returns the original Search object allowing for method chaining.



How to use

PageSearch is not instantiated automatically. You can create a new instance of PageSearch anywhere within a layout, page or included partial. 


<?ev
    var pageSearch = new PageSearch;
    pageSearch.within(page.topAncestor).exclude(page).limit(10).orderBy('sequence:asc');
    for(var result of pageSearch.results){
        // do something
    }
?>