Last updated Apr 20th, 2021 | 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.
$292 per month—let's make that $500!Learn more
Get an xPDO configuration option value by key.
API Docs: https://api.modx.com/revolution/2.2/db_core_xpdo_xpdo.class.html#\xPDO::getOption()
mixed getOption (string $key [, array|null $options [, mixed $default [, boolean $skipEmpty]]] )
$key: the key of the setting or option to load.
$options: the source of the setting or option. Either null (which attempts to find the key in the main configuration) or an array of options.
$default: the value to return when the key was not found.
$skipEmpty: when set to true, the $default will also be returned if the $key's value is an empty string. Added in xPDO 2.2.1 / MODX 2.2.0-rc2.
Get the table prefix:
$tablePrefix = $xpdo->getOption(xPDO::OPT_TABLE_PREFIX);
Get an option from a user-specified array, and if not set, check for it in $xpdo->config. If it's not set there, return false as its default value:
$mySetting = $xpdo->getOption('my_setting',$myConfig,false);