Website themes using CSS and PHP

chris

Free to Fly
Joined
9 Sep 2002
Messages
1,109
I have seen dotted about sites that use php to select which css stylesheet is loaded, giving the visitor the option of changing the theme of the page.

does anyone use this? i have a sort of idea how this could be done i was just wondering if there was anyone already using something like that
 
Sounds geh.
PHP:
<?php
switch($css) {
case blue:
$css = "blue.css";
setcookie ("3nigmaTheme", "blue.css", time()+3600*24*30*12*10);
break;
case white:
$css = "white.css";
setcookie ("3nigmaTheme", "white.css", time()+3600*24*30*12*10);
break;
default:
$css = "white.css";
break
}
?>
//site code here
<?php
if (!$_COOKIE['3nigmaTheme']) { 
  print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$css\" />";
 } else {
  print "<link rel=\"stylesheet\" type=\"text/css\" href=\"$_COOKIE[3nigmaTheme]\" />";
 }
}
?>
 
No problem, the top part needs to be at the very top (so it can set the cookie.. which lasts for 10 years btw :p as there is no method to set a permenant cookie) and the second part can go anywhere as long as it's within the head tags
 
heh damn SPeedY_B beat me to it

oh yeah and wewt the PHP tags work properly in Firebird
 
Noticed that too, must be the new vB build, hurah hurah and so forth :)
 
Personally my site uses different HTML pages and different CSS, this way you can dynamically load the entire site creating it part by part and then using the template parts to build a totally dynamic page.
 

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