FieldtypePage::findReferences() method

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

Latest news

  • ProcessWire Weekly #550
    In the 550th issue of ProcessWire Weekly we're going to check out the latest core updates, introduce a new third party module called PagefileMetadata, and more. Read on!
    Weekly.pw / 23 November 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer