August 24, 2012

Portal Access Based On User Locale in DNN 6.2.0


We were trying to figure out how to redirect a user to the DNN 6.2 by using their locale set at the profile through code. There was no way was available to do this, but finally did a workaround.

If you have enabled localization in your site, once you logged as host, then In the Logged In User view you will see the English, and other languages installed. If that has been set lets say to French, then all the site users will have the chnace to chnage their language by using this Logged In User section. But what if we want to navigate users to the site using their language set in the profile.

I tried many ways but their is no way that I could find to set the language by user locale. So as a workaround, used the following code sample to direct the user by locale.


int tabId = new TabController().GetTabByName(pageName, this.PortalId).TabID;//get the current page tab id

string targetUrl = Globals.NavigateURL(tabId); // get the url set
Dictionary<string, Locale>.ValueCollection locales = LocaleController.Instance.GetLocales(this.PortalId).Values; // get all the locales installed in the machine
int count = 0;
///Loop through all the locales and get the user locale and replace it
///with the locale added to the current
if (!String.IsNullOrEmpty(user.Profile.PreferredLocale))
            {
                foreach (Locale locale in locales)
                {
                    if (targetUrl.Contains(locale.Code))
                    {
                        targetUrl = targetUrl.Replace(locale.Code, user.Profile.PreferredLocale);
                        break;
                    }
                    if (targetUrl.Contains(locale.Code.ToLower()))
                    {
                        targetUrl = targetUrl.Replace(locale.Code.ToLower(), user.Profile.PreferredLocale.ToLower());
                        break;
                    }
                    if (targetUrl.Contains(locale.Code.ToUpper()))
                    {
                        targetUrl = targetUrl.Replace(locale.Code.ToUpper(), user.Profile.PreferredLocale.ToUpper());
                        break;
                    }
                }
            }


Response.Redirect(targetUrl);


This is only a workaround for this issue. :)

Setting up a Custom Login Page For DNN 6.2.0


Over the past few weeks I was wondering how to chnage the DNN default login page to a custom login page. The default login page will be poped up even if we create a custom page. refer the below screen shot.



So we wanted to create a totaly custom page for the login, and then set it as the login page. Finally we found out a workaround to do so. Please refer the below steps to make it work.

  • Create a custom page with the name login. Specifically you need to have it as login, because when you the users try to access a page without login, then automatically DNN will direct the user to a login.aspx page. So you have to have it by this name.

  • Then Add your custom module created for login, in to the page, and make all styles as you need.

  • In DNN 6.2 you have a module called, "Account Login" which has to be their in order to set the page as the login page. Othervise you will not be able to set the page as your login page.

  • Then Go to Manage > Settings of the "Account Login" module added.

  • Go to Permissions Tab, and then at the bottom, you will have a check box called "Inherit View permissions from Page" Ticked. Make sure to untick it and then have perssions given only to Administrator for View and Edit Module. And save the settings.

The page changes are completed, and now its time to do the site level changes.

  • Go to Admin > Site Settings > Advanced Settings

  • Set the Login Page to the page created above, the Login.aspx

  • And then click on the User Account Settings Tab

  • Expand the Login Settings

  • Set the Login.aspx page that you have created to the Redirect After Logout, and click on Update.
And Finally, now you can access your custom login page created, without any issue.