Theme Switcher (on website)

the_music_man

aka prodj88 =P
Joined
2 Jul 2002
Messages
2,401
Hi i was wondering if anyone could tell me how i can get a theme switcher for my site? all i want to do is let the users have the option to change the CSS background to black, blue, or red. its suppose to be a php code but i can't find it.
 
I'm guessing your using some kinda of CMS? If so check there site for themes perhaps. :)
 
CMS is an acronym for Content Management System
 
They way i do it is when you select your theme from the drop down box and press submit, it sets a cookies and refreshes the page, then at the top of the page checks the cookie and loads the corresponding CSS file.
 
yes, its all done in php, but theres no magical command "set_theme(blue)" or anything
you have to build up the code

setting cookies in php is easy
Code:
setcookie("NamOfCookie","value");
and to retrieve
Code:
$variablename=$_COOKIE["NamOfCookie"]
 
i still don't understand how to do it...where would i put the CSS filename??? are CSS files the same as cookies?? and what would be the value
 
CSS files are not the same as cookies.
 
Its the same way. They just spell it out simpler
 
im having problems on waht to put for the setcookie.php and style.php......i really don't know what to put in certain spots. i don't hvae a dark.css and i want to use my green.css and blue.css and default (tutlewax88.css)
 
Cahnge the code to match your Stylnames and css files.

Code:
<form action="style.php" method="post"><div>
<span class="underline">Stylesheet:</span>
<select name="style">
  <option value ="default">Default</option>
  <option value ="green">Green</option>
  <option value ="blue">Blue</option>
</select>
<br />
<input type="submit" value="click to submit" /></div>
</form>

style.php

PHP:
<?php
  if ($_POST["style"]=="green")
    {
      setcookie("style", "green", time()+2592000, "/");
    }
  elseif ($_POST["style"]=="blue")
    {
      setcookie("style", "blue", time()+2592000, "/");
    }
  else
    {
      setcookie("style", "", time()+2592000, "/");
    }
?>
<html>
<head>
<meta http-equiv=refresh content="0; URL=index.php" />
<body>
<h3>Applying theme</h3>
<a href="index.php">Click here if you aren't redirected</a>
</body>
</html>

setcookie.php

PHP:
<?php
  switch ($_COOKIE["style"])
  {
  case green:
  echo ('<link rel="stylesheet" type="text/css" href="css/green.css" />');
  break;
  case blue:
  echo ('<link rel="stylesheet" type="text/css" href="css/blue.css" />');
  break;
  default:
  echo ('<link rel="stylesheet" type="text/css" href="css/tutlewax88.css" />');  
  }
?>
 
off topic, but hey ~bk when i was in lebanon we saw the slr in downtown, it was a prince from UAE, and another prince had the new audi a8 all chromed out! talk about changing colors in cms LOL!
 
yeah i have the style.php and setcookie.php but it still doesn't work? and btw did u get my pm
 
themafia_69 said:
off topic, but hey ~bk when i was in lebanon we saw the slr in downtown, it was a prince from UAE, and another prince had the new audi a8 all chromed out! talk about changing colors in cms LOL!

blink.gif
tongue.gif
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back