You need the modContextSetting class, giving you key/value pairs for contexts, have a look at /core/model/modx/processors/context/setting/update.php for usage.
Use MODx, or the cat gets it!
Is it possible to add some code in my case statements that would over-ride and persist these custom context settings for the entire session?
I don’t think so. You can alter them for the duration of a *request*, or you can change them permanently in the DB. I could be wrong.
You could just include an external file into the plugin and put your code in that, this is the approach I adopt, from Frontpage for instance :-
/* Create a Frontpage class */
$corePath = $modx->getOption('frontpage.core_path',null,$modx->getOption('core_path').'components/frontpage/');
include_once $corePath . "model/frontpage/frontpage.class.php";
$fp = new Frontpage($modx);
$fp->initialize($scriptProperties);
Use MODx, or the cat gets it!
-
☆ A M B ☆
- 3,141 Posts
Indeed you can’t use [[snippetname]] in a plugin (or other snippet).
Use $modx->runSnippet(’snippetname’,array(’option’ => ’value’)) instead.
Thanks Mark.
I think I still have a fundamental problem if the context settings can not be persisted for only that visitor session.
My approach of changing the db value directly is going to be trouble because these are going to be overwritten every time the gateway resolves another host.
The values for the context settings need to be available throughout the site templates to dynamically change the content. What will happen is that the value of the setting will be different at any given moment based on the last visitor.
Uggg...
-Brian
Have you tried just calling $modx->setOption(’setting_key’,’setting_value’) in your switcher plugin?
shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect |
github |
splittingred.com