homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

Changing style sheets?
for color changes

 4:36 pm on Nov 13, 2002 (gmt 0)

I want to allow the viewer to change the background and text color. There are tutorials on how to do this in javascript with alternate style sheets but I would prefer to use php can't find any info on it.

Below is from the source of a site doing what I want

<link rel='stylesheet' type='text/css' href='/themes/orange/css-orange.css'>

<a href="index.php?theme=blue" onMouseOver="(window.status='Blue theme'); return true"></a>

Is there a script for this? If so, I can't find it.



 4:44 pm on Nov 13, 2002 (gmt 0)

The trick (or one of) is to carry a variable saying which sheet to use in a Session [php.net] which can be changed be links like you've given above.

<a href="blah.php?sheet=black">blah</a>

Then on each page you need to check $_GET['sheet']
and set the sheet like this:
then plonk the little fella in your html....



 5:57 pm on Nov 13, 2002 (gmt 0)

As of right now the only page using this would be the index page and should use the main sheet every time they revisit the page and have to change it per visit.

Or is that not how it works?


 6:00 pm on Nov 13, 2002 (gmt 0)

How do you want it to work?



 6:18 pm on Nov 13, 2002 (gmt 0)

I really don't know what I'm doing. I just started looking into this yesterday.

I wasn't sure if what you said before would be exactly what I needed, but it may be I really don't know.

I just want them to be able to click on the word black and change the background to black and the text to white, but the next time they visit my site if they want to see the black background again they would have to click on black again.

I don't know much about php and thought that there might be a copy and paste script to put in the html and then just add similar links like in my first message here.


 6:21 pm on Nov 13, 2002 (gmt 0)

Not that I know of....

Why would you want them to have to choose black again? -- A cookie that stores their preference might be nicer..

Admitedly I've not done this on a site I do similarly on but, it's on the TODO list ;)



 6:29 pm on Nov 13, 2002 (gmt 0)

I would be nice to save it in a cookie but to be honest it looks kind of tricky to accomplish especially since I've never done it before and seems to require a lot of information that I don't already know.

Thats why I was trying to find the easiest route possible.


 6:56 pm on Nov 13, 2002 (gmt 0)

if(!$sheet) {
$sheet="defualt"; // no cookie - get the default
setcookie("sheet", $sheet, time()+30412800); // set/reset cookie for a year

$stylesheet=$sheet."css"; // set stylesheet
<link rel="stylesheet" type="text/css"
href="<?=$stylesheet;?>" />

Untested, not properly thought out and likely not to work ;) But, may help get you started...



 7:02 pm on Nov 13, 2002 (gmt 0)

Thanks I will try it, even if that doesn't work it will still be helpful in figuring out how it works as an example.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved