If I want to include a php snippet inside another php snippet what would be the format?
I have [[functions]] - functions being the name of the snippet within another snippet, but it does not seem to be working.... I want it to work like a regular php include or require.
Thanks
Josh
-
☆ A M B ☆
- 24,524 Posts
A snippet is just plain php code that is passed through the eval() php function. So to include external php files, use an include, include_once, require, require_once function just as you would in any other php code. Keep in mind that a snippet behaves much like a php function, so any output needs to be returned. Echo and print statements do work, but can sometimes behave unexpectedly. Better to gather such output into a variable, then return the variable.
-
☆ A M B ☆
- 24,524 Posts
If this is in a snippet, you use
$modx->runSnippet('snippetName', array('option1'=>'value1', 'option2'=>'value2));
The array of options and values match the parameters you would normally use in the snippet tags.