get
Last updated Apr 6th, 2019 | Page history | Improve this page | Report an issue
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
Budget
$301 per month—let's make that $500!
Learn morexPDOObject::get()¶
Get a field value (or a set of values) by the field key(s) or name(s).
Syntax¶
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.
Examples¶
Get the name field value of the object.
$object->set('name','Charles');
$name = $object->get('name');
echo $name; // produces "Charles"
Get an array of values for multiple fields:
$object->set('name_first','Charles');
$object->set('name_last','Longbottom');
$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.
Backers
Budget
$301 per month—let's make that $500!
Learn more