PageSearch

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

Methods
childrenOf(Mixed:pages)

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..

Returns the original Search object allowing for method chaining.

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.

featured()

Restrict results to pages marked as featured.

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.

publishedSince(Date:date)

Find Pages published after a given date.

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
    }
?>
COVID-19 NOTICE – Business as Usual
Evance continues to provide all services and support throughout this difficult period. See our full statement here .