Jump to main content Jump to doc navigation


Get a foreign key definition for a specific classname. This is generally used to lookup classes in a one-to-many relationship with the current object.


API Docs: http://api.modxcms.com/xpdo/om/xPDOObject.html#getFKDefinition

array getFKDefinition (string $alias)


Get the FK definition of a User who just edited the Document.

$document = $xpdo->getObject('Document',1);
$fkdef = $document->getFKDefinition('EditedBy');

/* Outputs:
Array (
  [class] => User
  [key] => editedby
  [local] => editedby
  [foreign] => id
  [cardinality] => one
  [owner] => foreign
  [type] => aggregate
) */

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.


  • modmore
  • modmore
  • Jens Wittmann – Gestaltung & Entwicklung
  • Raffy
  • eydolan
  • Digital Penguin
  • Fabian Christen
  • Dannevang Digital
  • deJaya
  • Sepia River Studios
  • Following Sea
  • Anton Tarasov
  • Lefthandmedia
  • Nick Clark
  • Chris Fickling
  • Murray Wood
  • YJ
  • CrewMark
  • Richard


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

Learn more