Jump to main content Jump to doc navigation

modX::getParentIds

Gets all of the parent resource ids for a given resource.

Syntax

API Doc: modX::getParentIds()

array getParentIds ([integer $id = null], [integer $height = 10], [array $options = array()] )

Example

Get all of the parent IDs for the Resource with ID 23.

$parentIds = $modx->getParentIds(23);

Important! This method makes use of the context cache to get the parent IDs. If you don't specify the context in the options (third) parameter it will use the current context. In a plugin or external application that is often "mgr". When this method returns an empty array, it is most likely looking in the wrong context so you will have to specify the third parameter. Example:

$pids = $modx->getParentIds($id, 10, array('context' => 'web'));

See Also

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Jens Wittmann – Gestaltung & Entwicklung
  • Digital Penguin
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • eydolan
  • Following Sea
  • Anton Tarasov
  • Murray Wood
  • Lefthandmedia
  • Raffy
  • Stéphane Jäggi
  • Snow Creative
  • Nick Clark
  • Helen
  • JT Skaggs
  • A. Moreno
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

$348 per month—let's make that $500!

Learn more