matthieul
7 years agoAce
redirection many locale
Hello Lithosphere,
Context : I have a default locale (en) and an other fr
I have to set a default locale from user preferences and redirect it if user go to root url
My problem :
My code works well but not for root page, and if I disable the first line, my community will be down.
Can you help me ?
My code :
<#if page.name == 'CommunityPage' > <#assign preferred_lang = rest("/users/id/${user.id}/profiles/name/locale").value?trim /> <#if preferred_lang != '' > <#if preferred_lang == 'fr' || preferred_lang == 'France' > <#assign redirect_url = '/t5/FR/ct-p/francais' /> <#elseif preferred_lang?contains('en') || preferred_lang == 'English' > <#assign redirect_url = '/t5/EN/ct-p/english' /> <#else> <#assign redirect_url = '/t5/EN/ct-p/english' /> </#if> <#else> <#assign redirect_url = '/t5/EN/ct-p/english' /> </#if> ${http.response.setRedirectUrl(redirect_url)} </#if>
matthieul, replace your code with this in first condition
<#if !user.anonymous && page.name == "CommunityPage">
It will work like a charm.