Quote from: splittingred at Oct 13, 2008, 05:56 PM
Quote from: BobRay at Oct 13, 2008, 05:36 PM
Ok, is there any expectation that a snippet like Ditto or Wayfinder would typically have its own context and that the default properties of the snippet would be set here as context settings?
No, I wouldn’t expect those snippets to have their own context, though. They aren’t really meant for that - they are cross-context tools by their nature, working at pulling resources from specific contexts that they are already in.
I think you’re wanting default snippet parameters. 
Actually splittingred, no, he wants a combination of system settings and snippet properties in his case that can be overridden by context settings, because he has a set of components that are related; i.e. a "namespace" to encapsulate multiple Elements, some Resources, Settings, and Lexicon strings. You would only put values in them into the ’web’ context for the front-end, ’mgr’ and ’connector’ contexts for manager UI and AJAX management calls, if values needed to be overridden or added to the configuration loaded from system settings. Basically, each request loads the system settings, then merges contexts settings for a context when it is initialized, and finally, when a session is established, and the user loaded, any user settings are then merged over those. Then when a snippet is processed, the properties would be established as follows at runtime:
1. The default snippet properties are loaded from the database object.
2. Any tag properties (or properties passed to the process() function when called via API) are merged over top of the default.
3. The properties are passed into the function call for the snippet and extracted as variables in the local scope of the snippet.
4. The snippet can then decide to set the value of a variable based on if it is already set, and if not, use a named value from $modx->config (i.e. the result of merging system, context, and user settings). This is the ternary things you describe with a little more functional grace:
<?php
$spfconfig['spformProcID'] = isset($spformProcID) ? $spformProcID : $modx->config['spformProcID'];
$spfconfig['spfResponseID'] = isset($spfResponseID) ? $spfResponseID : $modx->config['spfResponseID'];
?>
And if you just use local variables instead of an array for your "config" (the properties are the config IMO), it’s even simpler:
<?php
if (!isset($spformProcID)) $spformProcID = $modx->config['spformProcID'];
if (!isset($spfResponseID)) $spfResponseID = $modx->config['spfResponseID'];
?>
Or, if you want to get really clever:
<?php
$spfconfig = array_merge($modx->config, $snippetProperties);
?>
with that, $spfconfig would have every system, context, user and snippet configuration setting (er, property, whatever

lol) at your disposal with very little effort.
And that gives me an idea for strenghtening the modNamespace concept as well. What I could do is simply make it so that you could get settings for a particular namespace by simply calling a function like $modx->namespace(’spform’); and we could automatically apply them into the properties for all Elements that are related to a namespace. I see a modNamespaceElement table in our future that will provide an alternative way to organize Elements into groups, for functional, rather than visual categorization; and with a many-to-many relationship (i.e. 1 Element can be in multiple Namespaces). This will be the functional equivalent of module dependencies in 0.9.6, except it applies to all elements by way of relation to a namespace, and the "shared parameters" are set (and potentially overriden) in the configuration.