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 #556
    In the 556th issue of ProcessWire Weekly we're going to share the latest core development news, highlight a new third party module, and more. Read on!
    Weekly.pw / 4 January 2025
  • 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

“Indeed, if ProcessWire can be considered as a CMS in its own right, it also offers all the advantages of a CMF (Content Management Framework). Unlike other solutions, the programmer is not forced to follow the proposed model and can integrate his/her ways of doing things.” —Guy Verville, Spiria Digital Inc.