After some fumbling, I’m able to create a new system setting in Revolution:
$temp_id = 2;
$newObj = $modx->newObject('modSystemSetting');
$newObj->set('key','spform_id');
$newObj->set('value',$temp_id);
$newObj->set('namespace','spform');
$newObj->set('area','SPForm');
$newObj->save();
The catch is that the system setting isn’t available in $modx->config[’spform_id’] until I manually clear the site cache, even though both the document and the snippet are uncached.
I tried:
$cacheManager= $modx->getCacheManager();
$cacheManager->clearCache();
and
but it’s still not there, even when I visit in another browser.
Also, what are the ramifications of setting "namespace" to "spform" versus "core"?
Is there a plan to load (and maybe unload) system settings on demand by namespace as we do with lexicons? That would free us up to use system settings in snippets without taking a significant performance hit.
I guess I should ask about my general strategy here, in case there are problems with it that I haven’t forseen.
For complicated reasons, I’m putting a document ID in system settings. In the snippet that uses it, I test for the system setting and, if it’s not there, I figure out what it should be (getting the document by name), then create it. The creation only happens the first time the page is accessed.
Down the road, I’ll probably do this in the build, but that will be more complicated and it’s working now except for the cache problem.