PagesParents::parents method

Get parents for given Page and/or specific columns from them

  • Return value has no exclusions for access control or status.
  • Return value order is closest parent to furthest.
  • This attempts to return all pages in 1 optimized query, making it potentially faster than other methods.
  • When using column or columns options, specify only one or the other, and include column(s) native to pages DB table only, with 1 exception—you may specify path as a column, which will return the generated page path(s).

Available since version 3.0.156.

Usage

// basic usage
$array = $pages->parents->getParents($page);

// usage with all arguments
$array = $pages->parents->getParents($page, array $options = []);

Arguments

NameType(s)Description
$pagePage int

Page or page ID

$options (optional)array
  • column (string): Just return array of values from this column (use columns option when you need multiple columns). Default:''
  • columns (array): Return array of associative arrays containing these columns for each page (not to be combined with column option)
  • indexBy (string): Return array indexed by column id or parent_id, applies only if given column/columns Default:''
  • includePage (bool): Also include data for given $page in return value? Default:false
  • noHome (bool): Omit homepage from return value Default:false
  • joinQty (int): Number of parents to join in query before going recursive, for internal use Default:4

Return value

array PageArray

If given column/columns returns an array, otherwise returns a PageArray


$pages->parents methods and properties

API reference based on ProcessWire core version 3.0.252