FieldtypePage::findReferences()

Return pages referencing the given $page, optionally indexed by field name

The default behavior when no arguments are provided (except $page) is to simply return a PageArray of all pages referencing the given one (excluding hidden, unpublished, trash, no-access, etc.). Specify "include=all" as your $selector if you want to include all pages without filtering. If the quantity may be large, you should also include a "limit=100" (replacing 100 with your limit). This method supports pagination when specifying a limit.

Usage

// basic usage
$items = $fieldtypePage->findReferences(Page $page);

// usage with all arguments
$items = $fieldtypePage->findReferences(Page $page, $selector = '', $field = false, bool $getCount = false);

Arguments

NameType(s)Description
$pagePage

Page to get references for

$selector (optional)string bool

Optionally filter/modify returned result, i.e. "limit=10, include=all", etc. Or boolean TRUE as shortcut for "include=all".

$field (optional)bool Field null

Optionally specify Field to limit results to (default includes all fields of this type), Or boolean TRUE to return array indexed by field name.

$getCount (optional)bool

Specify true to get a count (int) rather than a PageArray Default:false

Return value

PageArray array int

Returns one of the following, according to the provided arguments:

  • returns PageArray as default behavior, including when given a $selector string and/or Field object.
  • returns array of PageArray objects if $field argument is TRUE ($selector may be populated string or blank string).
  • returns int if the count option (boolean true) specified for $selector.

FieldtypePage methods and properties

API reference based on ProcessWire core version 3.0.251