API:setPlaceholder

From MODx Wiki

Jump to: navigation, search
 API Function Definition: 
setPlaceholder
Versions 
> 0.9.2
Return Values
Success: null
Fail: null
Data Type 
void
Object Hierarchy 
DocumentParser
void setPlaceholder(string $name, string $value);


setPlaceholder saves $value to an array with an index of $name. Placeholders are merged with the content when parseDocumentSource is called which, in turn executes mergePlaceholderContent. From there, the parse will take the array created by setPlaceholder and run through the content, replacing all instances of [+$name+] with $value.

Examples

$modx->setPlaceholder('jobtitle','Systems Engineer');
 
return 'I am a [+jobtitle+]!';

Related functions

Function source

File: manager/includes/document.parser.class.inc.php
Line: 1935
  1. function setPlaceholder($name, $value) {
  2. $this->placeholders[$name] = $value;
  3. }

Notes

This function is very simple, simply setting a value to an associative array. However, placeholders are a powerful tool when used correctly.

Personal tools