Bug: "Redirect after login" not redirecting to localized versions of page
I am currently working on DNN7, on a multilingual site (4 languages). The site has public registration and users must be redirected to a specific page after they complete their registration.
I found that DNN would not let me specify a different page for every language - in fact, if I went to Admin -> Site Settings -> User Account Settings -> Login Settings -> Redirect after Registration and selected a specific page in one language, it would give me <None Specified> if I went to the setting using another language.
This would probably have no impact if DNN took care to redirect the user to the localized version of the page after registration - which it doesn't (at least until version 7.0.6). So I had to alter a few things, which I'd like to share with you in case you are facing the same problem.
The problem seems to be on the \DesktopModules\Admin\Security\Register.ascx.cs file, which fortunately can be directly edited so no recompilation is needed. If you go to line 162 there, (the "else" portion of a rather large if statement), you'll see that it does the following:
_RedirectURL =
Globals.NavigateURL(Convert.ToInt32(setting));
Where "setting" is the Tab ID of the tab you have selected on the Site Settings section for redirecting after registration. This, of course, is not localized so it'll always take you the the actual page you have specified - regardless of the actual language the user is using to register.
In order to fix this, I copied and adapted some code from the language skin object (yes, the language picker) which can always find the right localized version of a page. So here's what I did:
I changed the line:
_RedirectURL =
Globals.NavigateURL(Convert.ToInt32(setting));
to:
int currentPortal =
PortalController.GetCurrentPortalSettings().PortalId;
Locale currentLocale =
LocaleController.Instance.GetCurrentLocale (currentPortal);
TabInfo localizedTab =
new TabController().GetTabByCulture(
Convert.ToInt32(setting), currentPortal, currentLocale);
_RedirectURL = Globals.NavigateURL(
Convert.ToInt32(localizedTab.KeyID));
And I also had to add two usings on top of the page:
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Entities.Portals;
With those changes, I managed to have the page to redirect to specified only once and have DNN redirect me to the page's localized version depending on the language I used to register.
Also please see here: http://support.dotnetnuke.com/project/All/2/item/26617 for other issues with Redirect after Login functionality. I applied the change to line 136 of the file mentioned in this issue, too.
One caveat: If you upgrade your DNN installation, you will probably lose those changes.
Also, have in mind that the same thing probably applies to the "Redirect after Login" functionality - I'll probably post something similar about that soon :). Plus, I have also created an SQL-based adaptation of GetTabByCulture to be used with OWS - I hope I have enough time to post this here too.
Standard disclaimer: Keep a backup of your initial Register.ascx.cs file. Don't blame me if this doesn't work for you. This is a solution that worked for my own project and it's not guaranteed to work in every case. Did I mention backup?
Until next time!
0 comments:
Post a Comment