Letting users choose color schemes

They have: 5,633 posts

Joined: Jan 1970

Hi everyone. First, thanks to everyone for all your knowledge and help! The Webmaster Forums, along with the SitePoint and JimWorld forums, have been an extraordinary resource for me.

Now to my question. I'm trying to find a way to offer visitors the ability to choose their own color schemes via a dropdown list of templates or styles. Basically, I want to emulate the setup at http://www.fanfiction.net -- if you look to the top right of their page, they offer a selection of "flavors" that will change the look of the entire site.

They seem to use a combo of CSS and cookies to achieve this, but it's beyond my scope of knowledge. I've found a product that sorta does what I want at http://www.richinstyle.com/free/mysite.html, but I'm not sure if this is the best solution.

Ideally, I'd like to change not only the font/table colors, but also images as well. (For example, using a blue logo with the blue template, a green logo with the green template, etc.)

Sorry for the length of the question. Am I making any sense? Anyone have a good way to go about this?

They have: 334 posts

Joined: Dec 1999

My 2 cents: (and that's all this advice is probably worth Smiling)

Adding a layer of complexity like that (especially if you're not 100% confident of how to implement it) is just asking for a headache. Letting the user pick a color scheme is little more than a useless toy. It does nothing to improve a site and I'd be willing to bet that very few visitors would use it. At least, they wouldn't use it beyond trying it once, saying "wow, kewl" and then never giving it another thought. You'd be a lot better served in the long run be devoting that energy to improving site content.

That said, actually doing it isn't too hard. There are probably a bunch of different ways to do it, and all would involve heavy use of style sheets and the most efficient would also use cookies although you can work around that with some sort of scripting like PHP or ASP. In a nutshell, the HTML code for a given page stays the same and the elements are defined with the various .css files. Whatever color scheme the user picks, the appropriate style sheet is loaded so that the appearance of the page changes without the underlying code changing. The style sheet choice is then saved in a cookie so that it "follows" the user from page to page and will stay set for repeat visits. To make that happen, just get yourself a good style sheet editor (I like Bradbury Software's TopStyle [url]http://www.bradsoft.com/topstyle/index.asp)[/url] and read a quick tutorial on simple cookies. Hopefully, by the time you're done you'll have given up on the idea, but you will have gained some valuable knowledge Wink

The idea of changing graphics makes things quite a bit harder. I could explain a way to do it with PHP, but it involves yet another layer of complexity (as well as creating multiple graphics sets) that just wouldn't be prudent without a real firm grasp of what's involved. Sorry to sound like a broken record, but in case you couldn't guess, I'm a die-hard member of the substance over style crowd and have found that tricks like that are usually a mask to cover poor or nonexistent content.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Hey klerner, welcome to TWF!

This is a big project. Especially if you want to change fonts and graphics. CSS is probably the best way to do this, as you can dynamically change everything (colors, fonts, and images) with JavaScript. With JavaScript, you would be able to set cookies, and keep the layout for each page, etc. etc.

I will be doing a souped up version for my site. (I may even include moving content around like Excite and Altavista). But I will be doing it all server-side with PHP and databases. That way, I can keep relational DBs, and track users.... They're color scheme, content scheme, what pages they frequent, their browsers type, OS, and more and more...

I would suggest looking for a prefab you can use, unless you have knowledge of JavaScript (or PHP), and the time to work with it.
try http://hotscripts.com and http://resourceindex.com

Good Luck,

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 19 posts

Joined: Feb 2001

I was doing that on my site a month or so ago, but decided to drop it: the upkeep on the CSS files and images for each style just wasn't worth it, and I decided one of my "schemes" was a lot better than the others, so I got rid of my scheme selector.

Anyway, if you want to do it, here's how I did it (one possible way, surely there are other more clever ways):

- I had a schemes directory, with a subdirectory for each of my supported schemes; these directories contained a css file, and a few image files (logos changed when the scheme changed, for example)
- I had a select in the navigation bar that listed the available schemes, and when a selection was made, would save the scheme name in a cookie, and do a location.href = location.href
- each page (via an include file, and by the way, this was all in ASP, you need some kind of server side script to do it, or at least it seems that way to me) would read the cookie, and create a "link href" statement in the page according to the selected scheme path
- references to the variable images was also created by script, using the value of the selected script directory
- Obviously, the entire site is CSS-aware, so that the UI paints according to the selected scheme (CSS and image files)

I finally decided to pitch it when I came to the conclusion that I needed multiple css files for different browsers (one for IE, one for NS4, one for NS6); just too much upkeep with n browsers x n schemes

StoreScanner.com - Local & online comparison shopping: audio, video, photo, appliances & more. Compare features, find rebates and coupons, link to manufacturers, find local & online stores.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

good point...
If/When I do it to mine, I'll probably do as much as possible using the server-side language. Using a cookie to store a userID, I'd query a DB for that users preferences. Then print table colors accordingly.

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.