Style Changer
On a few sites (like for example Suzanne's) there is an option of changing the style sheet that you are currently using, no doubt this can be done with PHP but how?
On a few sites (like for example Suzanne's) there is an option of changing the style sheet that you are currently using, no doubt this can be done with PHP but how?
Busy posted this at 07:37 — 24th January 2003.
He has: 6,151 posts
Joined: May 2001
several ways to do it, I think the most common is like:
if option a, use stylesheet 1
elseif option b, use stylesheet 2
else use default
Abhishek Reddy posted this at 08:34 — 24th January 2003.
He has: 3,348 posts
Joined: Jul 2001
If you have a member base, then store the user's choice in a db. If not, you could just pass data on by querystring, and on each page do what Busy says. Could even store the style choice in a cookie or in a session.
Renegade posted this at 09:09 — 24th January 2003.
He has: 3,022 posts
Joined: Oct 2002
Yes, I thought it would be something like that, but the real question is, how is it done? or what is one (the easiest and best) way to do it?
Suzanne posted this at 14:36 — 24th January 2003.
She has: 5,507 posts
Joined: Feb 2000
SET THE STYLESHEET:
<style type="text/css">
@import "/styles/advanced.css";
@import "/styles/<?php echo (!$sitestyle)?'default':$sitestyle ?>.css"; </style>
SAMPLE LINK:
<li id="websafe"><a href="/scripts/switchcss.php?set=websafe">Websafe Palette</a></li>
THE SCRIPT:
The script takes the variable and sets it as a cookie on the user's computer.
http://www.google.com/search?q=php+style+switcher
There are many open source php style switchers out there, read through the ALA article's comments for some insight into why one is better than another.
Renegade posted this at 10:54 — 25th January 2003.
He has: 3,022 posts
Joined: Oct 2002
Thanks Suzanne I'm going to try it out soon on my reading site
DC_Sara posted this at 12:42 — 25th January 2003.
She has: 392 posts
Joined: Jan 2002
I used skins and that seems to work the best for me. It sets a cookie and the person reading the site has an option of choosing the one that they want from a basic index page of the skins directory.
You can see it at work here: simplysara.com/blog/ and I have a tutorial here: graphics-by-sara.com under tutorials, under PHP
~*Sara*~
Renegade posted this at 11:27 — 2nd February 2003.
He has: 3,022 posts
Joined: Oct 2002
Thanks for the help everyone, finally finished a style found here:
http://chengeu.krayup.com/reading/index.php?page=body&maincss=blue
Suzanne posted this at 02:10 — 3rd February 2003.
She has: 5,507 posts
Joined: Feb 2000
Now make them a cookie so they stay!
Suzanne posted this at 02:12 — 3rd February 2003.
She has: 5,507 posts
Joined: Feb 2000
GG -- skins are the same thing as style switchers, only you have to create entire templates of html as well as just the stylesheet. When using valid markup and css positioning, you can use stylesheets to do everything and store the preference in a cookie.
Renegade posted this at 09:33 — 3rd February 2003.
He has: 3,022 posts
Joined: Oct 2002
i don't know how to set cookies :S
necrotic posted this at 21:40 — 3rd February 2003.
He has: 296 posts
Joined: May 2002
http://www.php.net/setcookie
Suzanne posted this at 21:51 — 3rd February 2003.
She has: 5,507 posts
Joined: Feb 2000
The alistapart article and the forums explain how to set cookies, hon.
Renegade posted this at 06:49 — 4th February 2003.
He has: 3,022 posts
Joined: Oct 2002
cool, thanks for the links, i'll have a look sometime this week
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.