Forum Discussion
Hi heavenerp,
I had completed a similar function weeks ago with Endpoint (like what PaoloT mentioned). more details can be found with http://lithosphere.lithium.com/t5/developers-discussion/Get-language-setting-of-current-node/m-p/128715#M4922
this week, I realised that there could be a simpler approach with "Page Initalization" (more details with Page Initalization can be found with http://lithosphere.lithium.com/t5/developers-discussion/Is-it-possible-to-make-a-redirect-with-REST-or-Freemarker/m-p/123591#M4666), after some simple test, I found that it works.
in short, we can just use the same hyperlink as you did for non-logged in users.
<a href="/t5/help/faqpage?profile.language=de">Click here to read this page in German</a>
and in "Page Initalization", you can have something like this
<#assign lang = http.request.parameters.name.get("profile.language", "")?trim /> <#if user.registered && lang?has_content && (lang?length > 0) > <#assign cur_lang = settings.name.get("profile.language", "") /> <#if cur_lang != lang > <#assign update_lang_setting = rest("/users/self/profiles/name/language/set?value=${lang}") /> ${http.response.setRedirectUrl(http.request.url)} <#-- Refresh the URL --> </#if> </#if>
note: http.response.setRedirectUrl is necessary as we need to re-load the language in user session.
I hope that this helps.
Related Content
- 12 months ago
- 10 years ago
- 7 months ago