• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Website themes using CSS and PHP

chris

Free to Fly
#1
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
 

SPeedY_B

I may actually be insane.
#2
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]\" />";
 }
}
?>
 

SPeedY_B

I may actually be insane.
#4
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
 

X-Istence

*
Political User
#8
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 posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,961
Messages
673,239
Members
89,014
Latest member
sanoravies