Jump to main content Jump to doc navigation


Get a field value (or a set of values) by the field key(s) or name(s).


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

mixed get(
   string|array $k,
   [string|array $format = null],
   [mixed $formatTemplate = null]

Do not use the $format parameter if retrieving multiple values of different types, as the format string will be applied to all types, most likely with unpredicatable results. Optionally, you can supply an associate array of format strings with the field key as the key for the format array.


Get the name field value of the object.

$name = $object->get('name');
echo $name; // produces "Charles"

Get an array of values for multiple fields:

$names = $object->get(array('name_first','name_last'));
echo $names['name_first'].' '.$names['name_last'];
// produces "Charles Longbottom"

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.



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

Learn more