i have two contexts
(de|en) and want to fill in a TV by passing a context-related lexicon-entry into it OnDocFormSave.
I tried a few things, but only get the proper output for the standard context
(de), not my second context
(en). For the second context the output is the unprocessed lexicon placeholder itself.
$modx->lexicon('my.placeholder'); outputs the de-value in both contexts
$modx->lexicon('my.placeholder', array(), 'de'); standard context, works fine
$modx->lexicon('my.placeholder', array(), 'en'); second context, outputs my.placeholder
I also tried
$modx->lexicon->load('en:namespace:default'); without luck
Is the setting
cultureKey correctly set for both contexts?
$modx->lexicon->load('en:namespace:topic'); should work.
Did you use the correct values for “namespace” and “topic”?
cultureKey is set correctly for both contexts.
[[++cultureKey]] works as expected in the frontend.
No typos, namespace and topic values are correct.
Strangely, this here outputs “de” in each context:
$culturekey = $modx->getOption('cultureKey');
$modx->lexicon->load('de:namespace:topic'); outputs the value for “de” in both contexts
$modx->lexicon->load('en:namespace:topic'); outputs “my.placeholder”, which is the placeholder, not the value
Coming closer… this here works:
$lex = $modx->lexicon('my.placeholder', array(), 'en');
If I delete
array(), things stop working.
So in order to pass in the cultureKey dynamically i need to fetch that.
$modx->getOption('cultureKey'); output “de” in each context?
In fact: it doesn’t matter which SystemSetting i am trying to get. I always get the values from my main context using this:
This is my
I think the problem is, that when the plugin is executed you are always in the “mgr” context.
So you probably have to get the correct context from the resource
$resource->get("context_key") and then use this information for the language.
That works. Thanks a lot, @halftrainedharry !
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.