modX.runSnippet
modX::runSnippet
Process and return the output from a PHP snippet by name.
Syntax
string runSnippet (string $snippetName, [array $params = array ()])
-
$snippetName
(string) The name of the Snippet you wish to call. required -
$parameters
(array) Key value pairs of parameters to pass to the snippet, equivalent to&key=
value``
API Doc: http://api.modx.com/revolution/2.2/db_core_model_modx_modx.class.html#%5CmodX::runSnippet()
string runSnippet (string $snippetName, [array $params = array ()])
Example
Run the 'Welcome' snippet with some custom parameters:
Examples
$output = $modx->runSnippet('Welcome',array(
'name' => 'John'
));
echo $output; // prints 'Welcome John!'
Handy Hint
When you call a Snippet using runSnippet, the Snippet code is always executed: the results are never returned from cache. It's equivalent to running the Snippet using the [[!uncached]]
syntax.