Selector class - ProcessWire API

  • Serves as the base class for the different Selector types (SelectorEqual, SelectorNotEqual, SelectorLessThan, etc.)
  • The constructor requires $field and $value properties which may either be an array or string. An array indicates multiple items in an OR condition. Multiple items may also be specified by pipe “|” separated strings.
  • Operator is determined by the Selector class name, and thus may not be changed without replacing the entire Selector.
// very basic usage example
// constructor takes ($field, $value) which can be strings or arrays
$s = new SelectorEqual('title', 'About Us');
// $page can be any kind of Wire-derived object
if($s->matches($page)) {
  // $page has title "About Us"
}
// another usage example
$s = new SelectorContains('title|body|summary', 'foo|bar');
if($s->matches($page)) {
  // the title, body or summary properties of $page contain either the text "foo" or "bar"
}

List of core selector-derived classes

  • SelectorEqual
  • SelectorNotEqual
  • SelectorGreaterThan
  • SelectorLessThan
  • SelectorGreaterThanEqual
  • SelectorLessThanEqual
  • SelectorContains
  • SelectorContainsLike
  • SelectorContainsWords
  • SelectorContainsWordsPartial 3.0.160+
  • SelectorContainsWordsLive 3.0.160
  • SelectorContainsWordsLike 3.0.160
  • SelectorContainsWordsExpand 3.0.160
  • SelectorContainsAnyWords 3.0.160
  • SelectorContainsAnyWordsPartial 3.0.160
  • SelectorContainsAnyWordsLike 3.0.160
  • SelectorContainsExpand 3.0.160
  • SelectorContainsMatch 3.0.160
  • SelectorContainsMatchExpand 3.0.160
  • SelectorContainsAdvanced 3.0.160
  • SelectorStarts
  • SelectorStartsLike
  • SelectorEnds
  • SelectorEndsLike
  • SelectorBitwiseAnd

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Selector class also inherits all the methods and properties of: WireData and Wire.

Properties

NameReturnSummary 
Selector::altOperators array Alternate operators to use when primary fails match, supported only by compareTypeFind. 3.0.161
DEFAULT: []
 
Selector::forceMatch null bool When boolean, forces match (true) or force non-match (false).
DEFAULT: null
 
Selector::group string null Group name for this selector (if field was prepended with a "group_name@").  
Selector::not bool Is this a NOT selector? Indicates the selector returns the opposite if what it would otherwise.  
Selector::quote string Type of quotes value was in, or blank if it was not quoted. One of: '"[{(  
Selector::str string String value of selector, i.e. “a=b”.  

Additional methods and properties

In addition to the methods and properties above, Selector also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.255