Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Change the Skin in codeChange the Skin in code
Previous
 
Next
New Post
8/10/2007 9:14 PM
 

I was wondering if someone could give me a code snippet of how to change the skin of a page and/or a container from code, such as on a button click.
Or point me in the right direction of where to get that info. :)

I'm looking to allow my users to change what skin is used so they have some customization of how the site looks.

Thanks

 
New Post
8/12/2007 1:10 PM
 

I haven't tested this, but it seems like you should be able to use something like this:

 

DotNetNuke.UI.Skins.SkinController.SetSkin("Containers", PortalId, Skins.SkinType.Portal, "[G]Containers/DNN-Blue/Text Header - White Background.ascx")

You will probably want your button click to return an array of all the available containers (I think there's a GetSkins method for this).  Then, when the user selects the one they want, it sets the skin.

Interesting idea.  LMK how you make out.

 
New Post
8/12/2007 4:11 PM
 

I've seen a few professional (read - costs money) mods that allow users to select thier own skin. It is something I've been looking for a solution to for a while. Getting better with the DNN code makes it more likely I can get something done up myself.

That chunk of code does work, unfortunately it sets it for the entire site. I'm looking for a solution that just changes per user.

I have found a way to change the skin per user with a cookie, that is built into DNN, in the Default.aspx. (Didn't 'find' it in the default,aspx, found it mentioned somewhere)
One of the pro ones uses a cookie, not the same as the DNN cookie name, but I think, with a little creativity using the DNN cookie would work just fine.

My general idea behind this is to store the selection in a DB, and if the cookie says something else (shared computer) re-write the cookie with the users stored preference, or delete the cookie if the user hasn't selected. If you have mod on the 'Home' page write the cookie after they log in (no Expire date for session only) then the cookie will only be for that user. Of course, you can have it have an expire date to that it is always on for that computer.

It's nice that the ability to set the skin with a cookie is here, makes this much easier to do. :)

 Here's the simple code I have to make the cookie. I have hard set the skin, as I was just testing it out. The Cookie name needs to be _SkinSrc# where # s the PortalID.

            HttpCookie httpCookie = new HttpCookie("_SkinSrc" + PortalId.ToString());
            httpCookie.Value = "[G]/Skins/SmoothTech/skin";
            httpCookie.Path = "/";
            //httpCookie.Expires = DateTime.Now.AddYears(30); <-- Taken out to make it session only
            Response.SetCookie(httpCookie);

 

Even with all my rambling and broken thoughts, I hope this can help someone else with user selectable skinning.

 
New Post
8/12/2007 4:27 PM
 

This sounds interesting enough to invest a little time investigating.  I agree the db route is the better way to go.  Just so I'm clear, are you trying to allow the user to select a page skin or container style?

 
New Post
8/12/2007 4:35 PM
 

I'm mainly interested in the user being able to select the Page Skin. The container isn't too big of deal to be selected, as I deal with non-computer adept users a lot of the time, and I don't want to give them options they don't need. I have a plain white container that I currently use that works well for most skins I have.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Change the Skin in codeChange the Skin in code


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out