User Controlled Skinning

Last post 10-03-2005 5:10 PM by flanakin. 15 replies.

Sort Posts:

  • User Controlled Skinning

    09-28-2005, 8:59 AM
    • Participant
      1,901 point Participant
    • flanakin
    • Member since 10-05-2003, 3:06 PM
    • Washington, DC area
    • Posts 384
    I was wondering what needs to be done to allow users to select their own skin on a page (or all pages) like what's done on the DNN site. I haven't really noticed that anywhere; but maybe I'm missing something.
    Michael Flanakin | Microsoft Consulting Services
    www.michaelflanakin.com
  • Re: User Controlled Skinning

    09-28-2005, 11:00 AM
    • Participant
      1,610 point Participant
    • jjohns09
    • Member since 06-22-2002, 5:58 PM
    • Overland Park, Kansas
    • Posts 320

    What you see on the DotNetNuke site was created by Nik. You can download his Skinergy package at:

    http://skinergy.speerio.net/

    Jeff Johnson

    http://www.bestmodules.com - Modules, Skins & Skin Objects
  • Re: User Controlled Skinning

    09-28-2005, 11:15 AM
    • Star
      13,145 point Star
    • J7Mitch
    • Member since 10-19-2002, 1:23 PM
    • Posts 2,632
    • TrustedFriends-MVPs
    You just need to set the SkinSrc either in the querystring or in a cookie.

    More info here:
    http://forums.asp.net/884387/ShowPost.aspx
    John M.

    DotNetNuke Module for Performance
  • Re: User Controlled Skinning

    09-29-2005, 4:51 PM
    • Participant
      1,901 point Participant
    • flanakin
    • Member since 10-05-2003, 3:06 PM
    • Washington, DC area
    • Posts 384
    What cookie? I tried setting the SkinSrc cookie; but that didn't do anything. I have everything working correctly to switch between skins, I just need to know where to actually set the skin so it will load dynamically. I tried setting the active tab's skin in the Page_Load, but that didn't work. I've also tried setting a SkinSrc context parameter. Neither work.

    I tried looking at Sperio's Skinergy, but it didn't give me everything I need. I've got all that setup, tho, so I just need to know where to set the skin. I looked at Skinergy's source, but didn't see anything that was setting the actual skin at runtime.

    Michael Flanakin | Microsoft Consulting Services
    www.michaelflanakin.com
  • Re: User Controlled Skinning

    09-29-2005, 7:13 PM
    • Participant
      1,901 point Participant
    • flanakin
    • Member since 10-05-2003, 3:06 PM
    • Washington, DC area
    • Posts 384
    Ok, here's my issue: The code that determines the skin is on the skin itself. You'd think that this would occur to me a lot sooner, but obviously not Stick out tongue [:P] I really don't want to have to do a redirect every time someone uses an alternate skin (Response.Redirect to the page + "&SkinSrc=/path/to/my/skin.ascx"). I'm hoping there's a way around it; but I'm done for now... I'll just have to take another look tomorrow, I guess. I'm about sick of it, tho, so if anyone knows of a good way to do it, puh-leeeeease let me know!!!
    Michael Flanakin | Microsoft Consulting Services
    www.michaelflanakin.com
  • Re: User Controlled Skinning

    09-29-2005, 8:04 PM
    • Star
      13,145 point Star
    • J7Mitch
    • Member since 10-19-2002, 1:23 PM
    • Posts 2,632
    • TrustedFriends-MVPs
    I implemeneted it in my own SkinEngine so I create my own cookie, but the DNN framework is looking for a cookie called "SkinSrc" when it loads.
    I list all the skins I want to allow for the user in a drop-down box and after they select the one they want I store it in the cookie.

    So, all you should have to do is store that same query string value in a cookie with code like this.


    Dim oCookie As HttpCookie

    oCookie = New HttpCookie("SkinSrc")
    oCookie.Value = QueryStringEncode("path/to/your/skin.ascx")
    oCookie.Path = "/"
    oCookie.Expires = DateTime.Now.AddYears(-30)
    Response.Cookies.Add(oCookie)


    John M.

    DotNetNuke Module for Performance
  • Re: User Controlled Skinning

    09-30-2005, 2:14 PM
    • Participant
      1,901 point Participant
    • flanakin
    • Member since 10-05-2003, 3:06 PM
    • Washington, DC area
    • Posts 384
    I tried that and it didn't work. I'll have to try it again, tho. I know I bounced back and forth with the path I tried. Maybe that has something to do with it. The only thing I don't like about it is that other DNN sites on the same server will be affected by it - won't they? If so, it's not an adequate solution for me.
    Michael Flanakin | Microsoft Consulting Services
    www.michaelflanakin.com
  • Re: User Controlled Skinning

    09-30-2005, 2:32 PM
    • Star
      13,145 point Star
    • J7Mitch
    • Member since 10-19-2002, 1:23 PM
    • Posts 2,632
    • TrustedFriends-MVPs
    Yes, if you are running multiple portals then this will set the skin no matter what portal they are in.
    I added a couple extra keys to my implementation to limit it to a specif tab, and to also make it unique by portal.

    Unfortunately you won't be able to control that without changing or overriding the core Skin Engine.
    John M.

    DotNetNuke Module for Performance
  • Re: User Controlled Skinning

    09-30-2005, 3:39 PM
    • Member
      65 point Member
    • vaish_p
    • Member since 08-24-2005, 7:34 PM
    • Posts 13
    I have modified my default.aspx as thus

                ' load assigned skin
                If ctlSkin Is Nothing Then
                    If IsAdminSkin(PortalSettings.ActiveTab.IsAdminTab) Then
                        Dim objSkin As UI.Skins.SkinInfo
                        objSkin = objSkins.GetSkin(SkinInfo.RootSkin, PortalSettings.PortalId, SkinType.Admin)
                        If Not objSkin Is Nothing Then
                            PortalSettings.ActiveTab.SkinSrc = objSkin.SkinSrc
                        Else
                            PortalSettings.ActiveTab.SkinSrc = ""
                        End If
                    Else
                        Dim objUserInfo As UserInfo = UserController.GetCurrentUserInfo
                        Dim uid As Integer = objUserInfo.UserID
                        If uid = -1 Then
                            uid = 0
                        End If
                        If Request.Cookies("_User_Skin_Pref" & PortalSettings.PortalId.ToString & "_" & uid) Is Nothing Then

                            Dim objUserSkinPref As HttpCookie
                          
                            objUserSkinPref = New HttpCookie("_User_Skin_Pref" & PortalSettings.PortalId.ToString & "_" & uid)
                            Dim objUserSkin As DotNetNuke.UI.Skins.CRV_UserSkinInfo
                            Dim objUserSkinC As DotNetNuke.UI.Skins.CRV_UserSkinController
    I am retreiving the skins for a user from db.. but u could choose to do it differently

                            objUserSkin = objUserSkinC.CRV_GetUserSkin(PortalSettings.PortalId, objUserInfo.UserID, "Skins")
                            If Not objUserSkin Is Nothing Then
                                Dim userskinsrc As String
                                userskinsrc = objUserSkin.SkinSrc
                                objUserSkinC.CRV_FormatSkinSrc(userskinsrc, PortalSettings)
                                objUserSkinPref.Value = objUserSkinC.CRV_FormatSkinSrc(userskinsrc, PortalSettings)

                            Else
                                objUserSkinPref.Value = ""
                            End If
                            PortalSettings.ActiveTab.SkinSrc = objUserSkinPref.Value
                            Response.AppendCookie(objUserSkinPref)
                        Else
                            Dim objUserSkinPref As HttpCookie
                            objUserSkinPref = Request.Cookies("_User_Skin_Pref" & PortalSettings.PortalId.ToString & "_" & uid)
                            PortalSettings.ActiveTab.SkinSrc = objUserSkinPref.Value
                        End If
                    End If


  • Re: User Controlled Skinning

    09-30-2005, 6:39 PM
    • Star
      9,585 point Star
    • cniknet
    • Member since 07-23-2002, 7:19 PM
    • Washington, DC
    • Posts 1,915

    You can setup user-selectable skins by using a very simple skin that acts as a loader. For instance, here's a skin that loads a different skin based on the browser:

    Switcheroo.ascx
    ===========

    <%@ Control language="c#" %>
    <script runat="server">
     protected void Page_Load(object s, EventArgs e)
     {
                string browser = Request.Browser.Browser.ToLower();
                string version = Request.Browser.MajorVersion.ToString();

                if (Request.QueryString["debug"] != null)
                    Response.Write(browser + version + ".ascx");
         else
                {
          try
                 {
               this.Controls.Add(this.LoadControl(browser + version + ".ascx"));
                 }
                 catch
                 {
               this.Controls.Add(this.LoadControl("Default.ascx"));
     
                 }
          }
     }
    </script>

    You can use this same technique to look-up a skin name from a user's profile and have it displayed, or alternately, present a list of available skins and once a user makes a selection, store it in a cookie with the portal ID as part of the key. On subsequent visits, you can force the display of the last selected skin.

    If this is of interest to more people, I can add it to the Skinergy suite.

    Nik


    Nik Kalyani
    Speerio, Inc.

    [DotNetNuke and ASP.Net solutions here]
  • Re: User Controlled Skinning

    10-01-2005, 7:10 AM
    • Star
      9,585 point Star
    • cniknet
    • Member since 07-23-2002, 7:19 PM
    • Washington, DC
    • Posts 1,915
    I was checking out the code to understand how the cookie-based skin that John referred to works and found this reference:

                ' load user skin ( based on cookie )
                If ctlSkin Is Nothing Then
                    If Not Request.Cookies("_SkinSrc" & PortalSettings.PortalId.ToString) Is Nothing Then
                        If Request.Cookies("_SkinSrc" & PortalSettings.PortalId.ToString).Value <> "" Then
                            PortalSettings.ActiveTab.SkinSrc = objSkins.FormatSkinSrc(Request.Cookies("_SkinSrc" & PortalSettings.PortalId.ToString).Value & ".ascx", PortalSettings)
                            ctlSkin = LoadSkin(PortalSettings.ActiveTab.SkinSrc)
                        End If
                    End If
                End If

    Unless I am mis-interpreting the code, it looks like you need to have a cookie named "_SkinSrcX" where X is the PortalID.

    Nik

    Nik Kalyani
    Speerio, Inc.

    [DotNetNuke and ASP.Net solutions here]
  • Re: User Controlled Skinning

    10-01-2005, 9:58 AM
    • Star
      13,145 point Star
    • J7Mitch
    • Member since 10-19-2002, 1:23 PM
    • Posts 2,632
    • TrustedFriends-MVPs
    Nik, is right.  That's what I get for trying to go by memory. Embarrassed [:$]
    Everything is there if you put the underscore in front and the portal id on the end.

    Sorry about that.
    John M.

    DotNetNuke Module for Performance
  • Re: User Controlled Skinning

    10-01-2005, 12:17 PM
    • Participant
      1,901 point Participant
    • flanakin
    • Member since 10-05-2003, 3:06 PM
    • Washington, DC area
    • Posts 384
    Ya know, that'd explain why it didn't work when I tried SkinSrc Stick out tongue [:P] I've got no complaints about _SkinSrc#! I'll have to switch to that on Monday. Thanks for all the input. I guess I should've dug thru the code earlier.

    Michael Flanakin | Microsoft Consulting Services
    www.michaelflanakin.com
  • Re: User Controlled Skinning

    10-03-2005, 2:45 AM
    • Member
      410 point Member
    • CurlyFro
    • Member since 05-16-2003, 6:20 PM
    • Posts 92
    i'm trying to do something very similar but i'd like to change the skin based on a users internet connection speed.  if they have a low bandwidth connection i'll load a skin with static images, if they have a high bandwidth connection i'll load media rich content.  i've been stuggling with creating the selectable vbscript all day.  can someone give me a vbscript example of how this would be down with cookies?
    thanks.

    -ty
  • Re: User Controlled Skinning

    10-03-2005, 12:31 PM
    • Member
      240 point Member
    • thegoldwater
    • Member since 07-26-2003, 3:57 PM
    • Maryland
    • Posts 48
    If you look at the main dotnetnuke home page, there is a menu bar across the top for setting the layout and the size based on skin... it uses a javascript function to set the cookie:

    <script language="Javascript">
    function setSkinCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
    }
    </script>
    i am sure this could work

    Best,





    Tim Patterson
Page 1 of 2 (16 items) 1 2 Next >