Remove language prefixes from specific pages

Ger Vang asked on December 2, 2014 16:34

I'm managing a website that has two languages, Spanish and English. I don't want a user to be able to switch language through the URL on Registration Page 1 and Registration Page 2. Whatever language they start off with on Registration Page 1 must complete Registration Page 2 with that language. Is there a way to not allowed changing languages on certain pages? I know there's a setting under CMS SITE MANAGER > SETTINGS > URLS AND SEO > Use language prefix for URLs or Allow URLs without languages prefixes but that's a site global setting. Any help?

Correct Answer

Ger Vang answered on December 3, 2014 21:17

Thank you guys. After fiddling with the code a bit, I came up with a solution.
* Set a new cookie [CMSRegStartCulture] with the given [CMSPreferredCulture] value. * On Registration Page 2, check to make sure [CMSPreferredCulture] cookie is equal to [CMSRegStartCulture] * If the two cookies doesn't match, take them back to Registration Page 1 and changed [CMSPreferredCulture] to equal the new cookie [CMSRegStartCulture]

This code seems to be working for me.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on December 2, 2014 20:34

How are they changing their language? Dropdown selection or button click on the front client side? You could simply hide that webpart/control if they are on the registration page(s). That doesn't mean they can't change the prefix in the URL but they are less likely to.

0 votesVote for this answer Mark as a Correct answer

Martin Danko answered on December 3, 2014 14:49 (last edited on December 3, 2014 14:52)

Hello Ger,

I'm afraid it won't be possible to implement it in the way that you are willing to. But as Brenden has suggested, you can simply hide the web part for language switching via the Visibility property where you can use macros to show/hide web part. But of course.. the user will be still able to change the URL manually but who would do that? Visitors usually don't even have idea how the urls work and also... they shouldn't know what languages, i.e. prefixes are available.

Best regards, Martin

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.