MODX Community

Client config not working with multiple contexts?

Him
i have installed CC on MODX 2.7.1 with 2 contexts. i have a template i use in both contexts and in there i have
[[++label]]
Now, in CC in context1 i fill in ‘Label1’ en in context 2 ,‘Label2’. I would expect each label to show up in the correct context on a page. But instead i see nothing. Only when using the ‘context’ Global will the label show up in both contexts. But… ,offcourse, with the wrong value.
What am i doing wrong?
tnx
RDG

1 Like

whats the value that is outputting? wrong on both contexts?

No, on both contexts the value for ‘web’ is shown. I’m calling the key uncached
[[!++MyLabel]]

looks like a line in the ClientConfig plugin isn’;t working.
$contextKey = $modx->context instanceof modContext ? $modx->context->get('key') : 'web';
allways returns ‘web’ in both contexts…

Ah ok, that is some good sleuthing! I would expect someone can help with this, I can’t, sorry. But its trivial to get the context key…

Here check this out, this guy’s question is diferent but he gives code for getting the key

https://forums.modx.com/thread/104944/how-to-get-the-name-of-the-current-context

$modx->context->key
$modx->resource->context_key

This indicates a conflict between the context router and clientconfig. As I’ve already discussed in numerous issues, CC runs before the context routing, so it defaults to web.

To fix, adjust the plugin events for either the router, or clientconfig. Set the router to use OnMODXInit, or set ClientConfig to use OnHandleRequest and make sure the priorities are set in such a way that the router runs first.

1 Like