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 CSS at runtime (per user?)Change CSS at runtime (per user?)
Previous
 
Next
New Post
1/27/2008 9:11 AM
 

I would like to allow my users to choose a colour scheme (my site is by default white text on a black background, but some users find this tiring and would like to choose a more conventional black-on-white).

One "easy" way which occurs to me is to have an alternative skin.css file for these users.

Can anyone suggest how I could implement this - allow some users to choose the alternative colour scheme?

And/Or - could I allow my users (even unauthenticated ones) to choose the alternative colour scheme by clicking an icon on the home page?

Thank you, Paul.

 
New Post
1/27/2008 9:56 AM
 

Choosing and keeping an alternative skin for your users is pretty simple.  You would need to provide links to switch between the skins you would like them to use.  When these links are click, you would then assign a cookie to the end-user which would specify the skin to load.  This cookie will override the skin specified at the page or site settings.

Due to the current limitations on the ability to set expirations for cookies in ASP.Net 2.0, I would suggest going with a JavaScript method of assigning this cookie, if you can.

If you consider the source in the Default.aspx.vb file:

' 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 = SkinController.FormatSkinSrc(Request.Cookies("_SkinSrc" & PortalSettings.PortalId.ToString).Value & ".ascx", PortalSettings)
            ctlSkin = LoadSkin(PortalSettings.ActiveTab.SkinSrc)
        End If
    End If
End If

Your cookie would need to be named "_SkinSrc", and its value would need to be the name of the skin, as it would be shown in the database.


Will Strohl

Upendo Ventures Upendo Ventures
DNN experts since 2003
Official provider of the Hotcakes Commerce Cloud and SLA support
 
New Post
10/14/2014 10:35 AM
 

For those that come later - the format should be:

Key: "_SkinSrc" + PortalId
Value: xxxFullSkinNameWithout.ascx"

So for example:

string skinSrc = "[G]Skins/DarkKnight/2-Column-Left-Mega-Menu.ascx"; //we will remove the .ascx
var cookie = new HttpCookie("_SkinSrc" + PortalSettings.PortalId, skinSrc.Replace(".ascx",""));
Response.Cookies.Add(cookie);



Andrew Walker

Learn to make your own beer and wine at homeIf you enjoy making your own beer and/or wine - be sure to check out http://www.ForemostBrewing.com
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Change CSS at runtime (per user?)Change CSS at runtime (per user?)


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