Reply LinkBack Thread Tools Search this Thread
Old 17-11-2008, 11:43   #1 (permalink)
vannquish
Registered User
 
Join Date: Oct 2007
Location: Midlands, UK
Posts: 46
User chooses CSS theme for site?

Whats the best way to use multiple css scripts on a site?

I want the user to be able to select what color they want the site to use and the site continues to use this theme while they navigate through the pages on the site.

Thanks
  Reply With Quote
Old 17-11-2008, 15:12   #2 (permalink)
INXS
Soy Chingon!
 
INXS's Avatar
 
Join Date: Sep 2008
Location: Washington, D.C.
Posts: 605
Send a message via MSN to INXS
that sounds like php good sir.
__________________
  Reply With Quote
Old 18-11-2008, 15:46   #3 (permalink)
MikeMackay
Shun the non-believer
 
MikeMackay's Avatar
 
Join Date: Feb 2005
Location: Essex, UK
Posts: 1,785
Send a message via MSN to MikeMackay Send a message via Skype™ to MikeMackay
As INXS said, you can achieve this with PHP. You'll want to be looking at cookies though (so the site can read the users' colour/display preference).

I've seen some nice live CSS switchers using JavaScript so you might want to look in to that too...

- Mike
__________________
  Reply With Quote
Old 18-11-2008, 16:33   #4 (permalink)
seen.to
unusual suspect ™
 
seen.to's Avatar
 
Join Date: Jul 2004
Location: DE, USA
Posts: 4,676
I used PHP for this on my portfolio (click on any of the 1-12 at the bottom) but I since prefer JavaScript solutions.
__________________
  Reply With Quote
Old 19-11-2008, 06:25   #5 (permalink)
vannquish
Registered User
 
Join Date: Oct 2007
Location: Midlands, UK
Posts: 46
is there any advantage or disadvantage to using the javascript solution?
  Reply With Quote
Old 19-11-2008, 06:54   #6 (permalink)
Shiro
Whitey
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 7,286
advantage - javascript doesn't require a page reload
disadvantage - if the user has javascript turned off (and many of us do), the switcher won't work.
__________________
This space for rent.

After Hours Japan
  Reply With Quote
Old 19-11-2008, 10:38   #7 (permalink)
weldo
now with added beard
 
weldo's Avatar
 
Join Date: Mar 2004
Location: Liverpool
Posts: 8,023
who disables javascript ???

and why ??
__________________
  Reply With Quote
Old 19-11-2008, 10:51   #8 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,614
People testing pages with javascript disabled.

They are testing pages with javascript disabled.
  Reply With Quote
Old 19-11-2008, 11:04   #9 (permalink)
weldo
now with added beard
 
weldo's Avatar
 
Join Date: Mar 2004
Location: Liverpool
Posts: 8,023
ha ha ... well, apart from those people and their testing processes ...

i'd assume they are using something like the web developers toolbar, and switch various things on and off for the afore mentioned testing purposes ...

joe public doesn't even know what javascript is, so why would he turn it off ??

i think he wouldn't ...
__________________
  Reply With Quote
Old 19-11-2008, 11:04   #10 (permalink)
MikeMackay
Shun the non-believer
 
MikeMackay's Avatar
 
Join Date: Feb 2005
Location: Essex, UK
Posts: 1,785
Send a message via MSN to MikeMackay Send a message via Skype™ to MikeMackay
Could always use JS first then go for a PHP fallback?
__________________
  Reply With Quote
Old 19-11-2008, 13:07   #11 (permalink)
Shiro
Whitey
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 7,286
That's how I would do it.

As for who disables javascript - I do. Pages load faster, because they don't need to load unnecessary crap. It also helps prevent some spyware from getting in, and allows you to decide if you are going to be tracked or not (google analytics etc). And any javascript-loaded advertising doesn't come through.

One of the more popular firefox addons out there is noscript (I use it), which disables javascript by default, and can be used to allow whichever domains you want.
__________________
This space for rent.

After Hours Japan
  Reply With Quote
Old 28-11-2008, 09:17   #12 (permalink)
KrisMarissens
or just Kris
 
KrisMarissens's Avatar
 
Join Date: Jun 2005
Location: Brussels - Belgium
Posts: 176
I would consider doing this in javascript only. That said I mean adding the necessary nodes (the hyperlinks that trigger the switch) and inner html through js and not adding them to the markup.

If javascript is disabled no cookie can be stored either to remember the choice. So unless you would be storing that data in a database there really is no point in being able to switch on the server side imho...
  Reply With Quote
Old 29-11-2008, 01:28   #13 (permalink)
Synook
What happened?
 
Synook's Avatar
 
Join Date: Jul 2008
Posts: 1,826
Quote:
Originally Posted by KrisMarissens
I would consider doing this in javascript only. That said I mean adding the necessary nodes (the hyperlinks that trigger the switch) and inner html through js and not adding them to the markup.

If javascript is disabled no cookie can be stored either to remember the choice. So unless you would be storing that data in a database there really is no point in being able to switch on the server side imho...
PHP can store cookies!
__________________
Web developer • AspektasBlogTwitter


  Reply With Quote
Old 29-11-2008, 04:37   #14 (permalink)
KrisMarissens
or just Kris
 
KrisMarissens's Avatar
 
Join Date: Jun 2005
Location: Brussels - Belgium
Posts: 176
I stand corrected...
The cookie would be sent along every session start then?

Last edited by KrisMarissens : 29-11-2008 at 05:05.
  Reply With Quote
Old 29-11-2008, 06:57   #15 (permalink)
Shiro
Whitey
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 7,286
All cookies are sent along with all http requests for the domain that they are set for - images, javascript, css and everything.
__________________
This space for rent.

After Hours Japan
  Reply With Quote
Old 29-11-2008, 09:06   #16 (permalink)
KrisMarissens
or just Kris
 
KrisMarissens's Avatar
 
Join Date: Jun 2005
Location: Brussels - Belgium
Posts: 176
I see... I guess that would not waste too much bandwidth, depending on the amount of traffic of course, since they are really tiny.
  Reply With Quote
Old 29-11-2008, 10:32   #17 (permalink)
Shiro
Whitey
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 7,286
This can still build up, and slow things down. For example, if you make 20 http requests on a page, the cookie is sent (and received) 20 times from the server.

One way you can get around this is to have the non-www version of your domain always forward to the www version of your domain. Then you create a subdomain, for example, static.domain.com, and you put any static images/javascript/css in the static domain. Since cookies are only sent for the domains for which they are a part of, and static.domain.com is not the same as www.domain.com, any requests to static.domain.com will not send the cookie. So in your html, you use an absolute URL with static.domain.com to get the images.
__________________
This space for rent.

After Hours Japan
  Reply With Quote
Old 29-11-2008, 21:21   #18 (permalink)
ponjoh
Registered User
 
Join Date: Nov 2008
Posts: 2
A List Apart has a great article about alternate style sheets. Check out alistapart.com/articles/alternate/.
  Reply With Quote
Old 30-12-2008, 02:43   #19 (permalink)
hkp819
Registered User
 
Join Date: Dec 2008
Posts: 27
I think php is good........
  Reply With Quote
Old 29-01-2009, 15:54   #20 (permalink)
lunitare
Registered User
 
Join Date: Jan 2009
Posts: 1
DynamicDrive CSS Switcher

I recently found a JS CSS switcher on Dynamic Drive.

Located under "User & System Preference" -> "Style Sheet Switcher"

Haven't had a chance to try it out, but thought I'd pass it on in case anyone else was looking for something similar.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive
Web Hosting by Heart Internet, vBulletin © 2000-2009 Jelsoft Enterprises Limited.
Search Engine Optimization by vBSEO 3.0.0 RC8
Web Hosting by Heart Internet