I have a snippet that gets some constants from a Property Set and uses some formulas to crunch some form input and output results.As of MODX 2.2, you can call modX::runSnippet(), modX::getChunk() and modParser::getElement() with Element names that include the Property Set, e.g.
I tried using this snippet as a FormIt hook (post-hook), but there is no way I can see to attach the specific property set.
My next thought was to use a middle-man snippet as the hook, and within it call my snippet via $modx->runSnippet() - but I still see no way to attach the property set.
Is there a way to do this? I know it can be done in tag format, so I'd assume it can be done programmatically as well.
$output = $modx->runSnippet('mySnippet@myPropertySet', $snippetProperties);
As of MODX 2.2, you can call modX::runSnippet(), modX::getChunk() and modParser::getElement() with Element names that include the Property Set, e.g.
$output = $modx->runSnippet('mySnippet@myPropertySet', $snippetProperties);
$scriptProperties['foo']
That is correct, or via $foo. And any additional scriptProperties would also be passed to override any properties from the property set using that call (i.e. I am passing in the scriptProperties assigned to the calling Snippet, or hook).
So, just to be clear - if @myPropertySet has a property called 'foo', and I use the call you made above, can I access it from within 'mySnippet' via
?$scriptProperties['foo']
And I'll get the 'myPropertySet' version of foo, rather than a version of foo that might be in the default property set for mySnippet?