Selector class

Selector maintains a single selector consisting of field name, operator, and value.

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

Show class?             Show args?        

Common

NameReturnSummary 
Selector::field()
string array nullGet the field(s) of this Selector
Can also be used as property: Selector::field
 
Selector::fields()
arrayReturn array of field(s) for this Selector
Can also be used as property: Selector::fields
 
Selector::get(string $key)
array mixed null stringGet a property 
Selector::matches($value)
boolDoes this Selector match the given value? 
Selector::operator()
stringReturn the operator used by this Selector
Can also be used as property: Selector::operator
 
Selector::set(string $key, mixed $value)
Selector WireDataSet a property of the Selector 
Selector::value()
string array nullGet the value(s) of this Selector
Can also be used as property: Selector::value
 
Selector::values()
arrayReturn array of value(s) for this Selector
Can also be used as property: Selector::values
 

Properties

NameReturnSummary 
Selector::forceMatch null bool When boolean, it forces match (true) or 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.135

Twitter updates

  • New post: Version 3.0.135 of ProcessWire on the dev branch focuses on some .htaccess updates, adds clarity to debug mode, and improves upon the installer— More
    5 July 2019
  • ProcessWire 3.0.133 adds a useful new Page::meta() method for a new type of page-specific persistent data storage, adds the ability for users to create their own bookmarks in Lister, and has a handy and time saving update for the asmSelect input type— More
    14 June 2019
  • New post: This week we’ll take a look at 3 different WEBP image strategies that you can use in ProcessWire 3.0.132+. Then we’ll dive into a major update for the Google Client API module, and finish up by outlining some useful new updates in FormBuilder— More
    31 May 2019

Latest news

  • ProcessWire Weekly #270
    This week in the 270th issue of ProcessWire Weekly we're going to cover the SearchEngine module, feature some recent support forum highlights, and introduce a brand new site of the week. Read on!
    Weekly.pw / 13 July 2019
  • ProcessWire 3.0.135 core updates
    Version 3.0.135 of ProcessWire on the dev branch focuses on .htaccess updates, adds additional layers of security, adds clarity to debug mode, and improves upon the installer.
    Blog / 3 July 2019
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH