Having several "themes"

Grandmaster

Electronica Addict
Political Access
Joined
3 Feb 2002
Messages
10,574
I want to be able to let the use pic from a list of themes from my site. I just want to do somthing simple, like maybe changing the header image and the colors.

I am think something like that would require the browser to load a new CSS file, with each theme having a different CSS file. I think its possible but I have no idea how to go ahead with it.

Any ideas?
 
Yup, CSS will be easiest. I'm sure Kunal will help out if you can find a sharp enough stick to poke him with 😛
 
*Cough*

Kunal
poke.png
Me

😛
 
If you wanna do what I think you do, you can set a cookie then have a different stylesheet loaded. There could be an easier way, but this is how I do it.

here is the head section of my index.php:

PHP:
<?php

ob_start( 'ob_gzhandler' );

?>

<?php 

  echo('<?xml version="1.0" encoding="ISO-8859-1"?>');

?>



<!DOCTYPE html 

     PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">



<head> 

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

<meta http-equiv="Content-Style-Type" content="text/css" />

<title>j79zlr's tips and tweaks :: homepage</title>

<link rel="icon" type="image/x-icon" href="favicon.ico" />

<?php

  include ('blocks/setcookie.php');

?>



</head>

then the form I use:

Code:
<form action="style.php" method="post"><div>

<span class="underline">Stylesheet:</span>

<select name="style">

  <option value ="default">Default</option>

  <option value ="dark">Dark</option>

</select>

<br />

<input type="submit" value="click to submit" /></div>

</form>

the style.php form action"

PHP:
<?php

  if ($_POST["style"]=="dark")

    {

      setcookie("style", "dark", time()+2592000, "/");

    }

  elseif ($_POST["style"]=="blue") 

    {

      setcookie("bg", "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>

and finally the setcookie.php

PHP:
<?php

  switch ($_COOKIE["style"])

  {

  case dark:

  echo ('<link rel="stylesheet" type="text/css" href="css/dark.css" />');

  break;

  default:

  echo ('<link rel="stylesheet" type="text/css" href="css/basic.css" />');  

  }

?>
 
o_87 said:
*Cough*

Kunal
poke.png
Me

😛

Hello 😀
Yeah, so try what j79zlr posted. If you have any trouble with it, or if that's not what you want, let me know, and I'll show you how I have it setup on e-piphany.
 
j79zlr's seems pretty straight forward, should work perfectly 🙂
 
Yep, works great. Thanks j79zlr. I haven't implemented it yet online, but I have it working locally on my pc. 😀

*gives j79zlr a rep point*
 
Yep, works great. Thanks j79zlr. I haven't implemented it yet online, but I have it working locally on my pc. 😀

*gives j79zlr a rep point*
 
Can you explain what how this file works:

<?php

if ($_POST["style"]=="dark")

{

setcookie("style", "dark", time()+2592000, "/");

}

elseif (
$_POST["style"]=="blue")

{

setcookie("bg", "blue", time()+2592000, "/");

}

else

{

setcookie("style", "", time()+2592000, "/");

}

?>

Just curious 🙂
 
That is the form action, so when the style is selected it writes the cookie. Then when any page is loaded it read said cookie and writes the corresponding stylesheet line. So when xyz is selected in the drop down box, it goes to that page, writes the cookie, and then returns to the index 🙂

If you want to see it in action, I only have it on my index page, http://www.j79zlr.com
 
another way to do it is:

first you add your default stylesheet:
<link href="default.css" rel="stylesheet" type="text/css" media="screen,projection" />

then you can use the "alternate stylesheet" arguement:
<link href="alternate.css" title="Red" rel="alternate stylesheet" type="text/css" media="screen,projection" />

but I dont think Internet Explorer supports this, I know Mozilla does though. For Mozilla, you can then select the stylesheet from the bottom-left corner.
 
CHiLLaXen said:
another way to do it is:

first you add your default stylesheet:
<link href="default.css" rel="stylesheet" type="text/css" media="screen,projection" />

then you can use the "alternate stylesheet" arguement:
<link href="alternate.css" title="Red" rel="alternate stylesheet" type="text/css" media="screen,projection" />

but I dont think Internet Explorer supports this, I know Mozilla does though. For Mozilla, you can then select the stylesheet from the bottom-left corner.

Or better yet, combine both methods like I have. 😉
 
Yeah, IE Doesn't support it, neither do Opera or Safari to my knowledge (?)
Also it's not saved like the cookie version.. unless that's changed since last time I visited a site that used it..
 
you can also do it with different XHTML code segments if you use the HEREDOC style in PHP and then just output the variables with the different code areas and test for a cookie value when you do the page and include a different xhtml code file depending on the cookie, thats how mine works
 

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 Electronic Punk 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 Sazar 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,016
Messages
673,499
Members
5,630
Latest member
REALMTBENJOYER
Back