Bookmark and Share

Friday, February 15, 2013

Hot to change the DotNetNuke skin “on the fly”

Here is how to change dynamically the DNN skin based on the user credentials, in my case I needed to show the standard DNN skin for the “host” user.
The code has been injected in the DNN default.vb file, but you can use the code inside a custom module.

VB.NET:

If Not DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.Username Is Nothing Then
If DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.Username.ToString() = "host" Then
TabController.CurrentPage.ContainerPath = "/Portals/_default/Containers/imagicle1/"
TabController.CurrentPage.ContainerSrc = "/Portals/_default/Containers/imagicle1/Article.ascx"
TabController.CurrentPage.SkinDoctype = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">"
TabController.CurrentPage.SkinPath = "/Portals/_default/Skins/MinimalExtropy/"
TabController.CurrentPage.SkinSrc = "/Portals/_default/Skins/MinimalExtropy/index 1280.ascx"
End If
End If


C#


if ((DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.Username != null)) {
if (DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.Username.ToString() == "host") {
TabController.CurrentPage.ContainerPath = "/Portals/_default/Containers/imagicle1/";
TabController.CurrentPage.ContainerSrc = "/Portals/_default/Containers/imagicle1/Article.ascx";
TabController.CurrentPage.SkinDoctype = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
TabController.CurrentPage.SkinPath = "/Portals/_default/Skins/MinimalExtropy/";
TabController.CurrentPage.SkinSrc = "/Portals/_default/Skins/MinimalExtropy/index 1280.ascx";
}
}


2 comments:

  1. find below article for how you can develop and modify DNN skins.
    http://www.packtpub.com/article/dotnetnuke-skinning-creating-first-skin
    DotNetNuke Developers

    ReplyDelete
  2. Thank you for your comment! Skins in DNN are very powerful, I have developed my own skins for my company.

    ReplyDelete