Hi,
I’m building a multi-lingual site using two contexts in MODx Revo 2.0.4-pl2.
The basic idea is:
www.domain.com = English (context = web)
www.domain.fr = French (context = web-fr)
I’ve got this working now, and the context is changing based on the url.
Where things are getting a little complex is when it comes to user logins. When a somebody logs in I want them to be logged into both the web and web-fr contexts.
I’m attempting to use the Login extra, but I’m having a little trouble getting this to work across the contexts. I took a peek through the Login snippet and noticed that it supports contexts (see below). I’ve been unable to find any documentation on how this actually works though.
$contexts = !empty($scriptProperties['contexts']) ? $scriptProperties['contexts'] : '';
$contexts = !empty($_REQUEST['add_contexts']) ? $_REQUEST['add_contexts'] : $contexts;
I managed to find something in google cache which explained these new parameters, for some reason the content wasn’t available on the live modx website.
Change multi-context support to use new login processor add_contexts parameter The login processor in Revolution v2.0.4 and later supports a new add_contexts parameter, which specify additional contexts to log the user into. These can be supplied as contexts. Note however that a primary loginContext is still required, but can be specified either as a snippet property or a login_context $_REQUEST parameter. The contexts property of the Login snippet should not include the primary loginContext. The property can be overridden via an add_contexts $_REQUEST parameter. To use via the add_contexts $_REQUEST parameter, add a hidden input field with the add_contexts to your login form, and an additional GET parameter on the logout form, specifying the additional contexts. Use via the context snippet property does not require any special $_REQUEST parameters. This usage is recommended.
Based on this my assumption has been that I can do something like:
[[!Login?
&tplType=`modChunk`
&loginTpl=`lgn_login`
&redirectToPrior=`1`
&loginResourceId=`21`
&contexts=`web-fr`
]]
When called from the login page of the ’web’ context, I presumed this should login the user to both ’web’ and ’web-fr’.
Alternatively, I should be able to add a hidden field to my login form to achieve the same thing:
<input type="hidden" name="add_contexts" value="web-fr" />
I may be completely wrong in my assumptions above, and I’ve been unable to get either of these methods to log me into both contexts at once. I can login to the contexts individually one by one, but never together at once.
Can anybody explain how I can use the Login extra to accomplish a multi-context login?
thanks for your help
Andrew