Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > User switchable CSS?

User switchable CSS?
Thread Tools
Dedicated MacNNer
Join Date: Aug 2000
Location: Harrisonburg, VA USA
Status: Offline
Reply With Quote
Nov 13, 2005, 07:14 PM
 
So how complicated is to implement a button that will let the user switch between two different style sheets? I looked around for a DW behavior with no luck and any sites I've found that have this feature all use javascript libraries that are a bit over my head, but it seems like it shouldn't be that complicated.

Thanks.
"Make good fight."
-Mr. Miyagi
     
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status: Offline
Reply With Quote
Nov 13, 2005, 07:25 PM
 
How about the ALA style switcher?

pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
     
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status: Offline
Reply With Quote
Nov 13, 2005, 07:25 PM
 
i use php to set a couple session vars to change link to style sheet and main header image.
The Bitcastle
graphic design, web development, hosting
     
Posting Junkie
Join Date: May 2001
Location: Brisbane, Australia
Status: Offline
Reply With Quote
Nov 13, 2005, 09:18 PM
 
Use the ALA-style switcher as mentioned.

Don't know if this is useful for anyone, but I just put together this bit of php-code to automatically switch stylesheet by date (spring, summer, fall, winter). I couldn't find anything by Googling on this, so I based this of a variable-setting one. It's a bit ugly, but then again I'm not much of a coder:
Code:
<?php if(date("n") == 12) { if(date("j") >= 22): echo "<link rel=\"stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title\"var\" />"; else: echo "<link rel=\"stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; endif; } if(date("n") >= 1 && date("n") <= 2) { echo "<link rel=\"stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title\"var\" />"; } if(date("n") == 3) { if(date("j") <= 21): echo "<link rel=\"stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title\"var\" />"; else: echo "<link rel=\"stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; endif; } if(date("n") >=4 && date("n") <= 5) { echo "<link rel=\"stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; } if(date("n") == 6) { if(date("j") <= 21): echo "<link rel=\"stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; else: echo "<link rel=\"stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; endif; } if(date("n") >= 7 && date("n") <= 8) { echo "<link rel=\"stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; } if(date("n") == 9) { if(date("j") <= 21): echo "<link rel=\"stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; else: echo "<link rel=\"stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; endif; } if(date("n") >= 10 && date("n") <= 11) { echo "<link rel=\"stylesheet\" href=\"layout-gold.css\" type=\"text/css\" title=\"host\" /> <link rel=\"alternate stylesheet\" href=\"layout-green.css\" type=\"text/css\" title=\"sommer\" /> <link rel=\"alternate stylesheet\" href=\"layout-spring.css\" type=\"text/css\" title=\"var\" /> <link rel=\"alternate stylesheet\" href=\"layout-blue.css\" type=\"text/css\" title=\"vinter\" />"; } ?>

[ fb ] [ flickr ] [] [scl] [ last ] [ plaxo ]
     
mdc
Addicted to MacNN
Join Date: Feb 2003
Location: NY²
Status: Offline
Reply With Quote
Nov 14, 2005, 01:06 AM
 
my site has a php script with cookies that will remember which style (selectable towards the bottom of the front page) you chose.

if you want the code i'll post it
     
Dedicated MacNNer
Join Date: Aug 2000
Location: Harrisonburg, VA USA
Status: Offline
Reply With Quote
Nov 14, 2005, 04:01 PM
 
Thanks guys, the ALA thing was just what I was looking for. The PHP stuff won't work since my students don't have access to a PHP server.

Thanks again!
"Make good fight."
-Mr. Miyagi
     
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status: Offline
Reply With Quote
Nov 14, 2005, 10:55 PM
 
Originally Posted by grovberg
The PHP stuff won't work since my students don't have access to a PHP server.
hmm thats pretty sad.

it comes with OS X you know - but you do have to 'turn it on' by editing a text file (way beyond some people i know).
The Bitcastle
graphic design, web development, hosting
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -4. The time now is 03:00 PM.
All contents of these forums © 1995-2014 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2014, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2