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

Latest news

  • ProcessWire Weekly #559
    The 559th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 25 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

“…building with ProcessWire was a breeze, I really love all the flexibility the system provides. I can’t imagine using any other CMS in the future.” —Thomas Aull