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.

3 Likes

Thanks so much Markh that worked

plugins → contextRouter → SystemEvents → tick onModxInt

I just had a similar issue using ClientConfig together with Babel and XRouting. In case somebody else has this problem in the future (including me), here is what I did:

Simply set the priority of the ClientConfig System Event OnHandleRequest to 1.

This did the trick for me. I use GatewayManager, and none of the other tweaks worked.

1 Like