Looking to add a button to a site that would enable a user to manually switch the language on a page.
I’m a bit stuck on how to achieve this. Was thinking of using a Get Variable for the Context Detection setup but not 100% how to actually set it all up. Would like to append the page url with something like ?language=languagetype whenever the context was in view.
Do you have a different URL for the different context? If not, you might run into problems when it comes to caching as Matrix or your proxy will cache one context for everyone in that case.
Ideally, if you are running cache and contexts, the best way is to apply a completely separate URL and target the context based on that. WOuld that work for you?
Thanks for this. It’s exactly what I was trying to achieve. How do you have the alternate context setup? i.e. what do you have in the condition details fields?
I’ve tried a few things but still can’t get it to display the context on the front end…clearly missing something
So I’ve gone ahead and got this work with a get variable. Caching appears to be ok although I’ve found an issue where it’s caching the content if you view in Edit and then go back to the content on the site - logging out fixes it.
Any ideas why this might be? Don’t get the same issue with admin or viewing the content as a public user…
Are the editors editing pages in Safe Edit at all, or are they editing page directly live?
Also, what caching mechanisms do you have in place? Matrix cache, Squid, or Edge?
Probably should have asked those earlier.
With Matrix cache, you can have group caching enabled, meaning that all users in the same group or with the same permission get the same cache entry. Which could explain the difference you see when you log out. But also if the editors are editing in Safe Edit, seeing the Safe Edit version when they view the page on the frontend, but then see different content as soon as they log out, would also explain it.
Editors are editing in under construction at the moment Bart.
It’s behaving the same for me as a sys admin. i.e. I go to the unpublished page on the frontend and it works fine even though I need to login via admin to view.
As soon as I login via Edit the page gets stuck in a single context on the frontend.
I’ve disabled Matrix Cache for the section of the site and we are using Edge.
Whatever context you were last viewing in edit seems to cache on the frontend.
So for example if you login and switch to context b, then go to the page itself it won’t switch to context a via the page button. Just remains stuck in b.
If you then go to the edit screen and switch to context a, it gets stuck in context a again.
Yea I think that’s expected if you are logged in as an editor. Mainly so that you don’t get confused that you just edited something in context B, view a page on the frontend and suddenly see context A. But I guess it also depends on the context setup you’ve got in the Context Configuration screen and which URLs you’ve got contexts applied to on the Site asset?
Oh right, if you are switching context with just a URL query it will not play nice with caching because as soon as you click on a different link you will lose the ?lang=x part and get the current context cached on the next URL for all users.
If you are using contexts for different languages and need to have caching enabled, it’s best to use different URLs for each context.
Makes sense to a certain extent but not getting the issue with live pages and logged out.
When I went for the url option I was getting similar issues with the added problem of the urls staying in context as a user travelled through the site - we only have a few pages that need a context so this wouldn’t make sense.
Think I might have to raise a ticket for it and see what the chat is.