modX.setPlaceholders
Last updated Apr 12th, 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
$194 per month—let's make that $500!
Learn moremodX::setPlaceholders¶
Sets a collection of placeholders from an array or object. An optional $namespace is prepended to each key in the collection to keep it apart from other placeholders.
Syntax¶
void setPlaceholders (array|object $placeholders, [string $namespace = ''])
No separator is inserted — neither between the namespace and the key nor between the levels of a nested array. setPlaceholders(['a' => ['b' => 1]]) with an empty namespace therefore sets a single placeholder called ab.
Nested arrays are concatenated the same way: getChunk and toPlaceholders insert a dot between levels, setPlaceholders does not. For multi-dimensional arrays and objects with non-scalar values, use modX.toPlaceholders, which delimits each level with a separator (a dot by default).
Example¶
Add an array of placeholders, and prefix my. to their keys.
$modx->setPlaceholders(array(
'name' => 'John',
'email' => '[email protected]',
),'my.');
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
Budget
$194 per month—let's make that $500!
Learn more










