The answer has been founded on the www!
This woman is a genius web designer (I love her site) and if anyone wants to use A List Apart’s ULTRA simple and effective PHP stylesheet switcher, no Javascript or plugin required, the answer’s here:
jet2k.com
Using the above ideas, whenever I click on the link, Safari outputs:
“The page you opened redirected you to a page that isn’t supported by Safari.
Safari can’t open the page “” because it cannot redirect to locations starting with “(null):”.”
The page simply fails to load in Firefox.
After some playing, I got it to work using this:
<?php setcookie(“style”, $_GET[“style”], time()+31536000);
header(“Location:”.$_SERVER[“HTTP_REFERER”]);
?>
in case it might help someone
The page is old, from 2002. Bad code..
Example usage:
Sidebar
´
<form action=”switcher.php” method=”post”>
<select name=”set”>
<option value=”1c-b”> » 1c-b</option>
<option value=”2c-l” selected=”selected”> » 2c-l</option>
<option value=”2c-r”> » 2c-r</option>
<option value=”3c-b”> » 3c-b</option>
<option value=”3c-l”> » 3c-l</option>
<option value=”3c-r”> » 3c-r</option>
</select>
<input type=”submit” value=”Change Style”>
</form>
´
Switcher.php
´
if (isset($_POST[‘set’]))
{
setcookie (‘style’, $_POST[‘set’], time()+31536000, ‘/’, ‘domain.org’, ‘0’);
header(“location: ” . $_SERVER[‘HTTP_REFERER’]);
}
´
header.php
´
<link rel=”stylesheet” type=”text/css” media=”screen” title=”Sandbox layouts” href=”/wp-content/themes/sandbox/css/<?php echo (!$_COOKIE[‘style’])?’2c-l’:$_COOKIE[‘style’] ?>.css” />
<link rel=”stylesheet” type=”text/css” media=”screen” title=”Base Style” href=”/wp-content/themes/sandbox/style.css” />
´
I can’t get this method to work to save my life. I’ve tried several different suggested methods of implementing this without success. In the process, I’ve now confused myself!
I have:
Sidebar
´
<form action=”wp-content/themes/crisp/switcher.php” method=”post”>
<select name=”set”>
<option value=”Spring”> » Spring</option>
<option value=”Pegasus” selected=”selected”> » Pegasus</option>
</select>
<input type=”submit” value=”Change Style”>
</form>
´
Switcher.php
´
<?php
if (isset($_POST[‘set’]))
{
setcookie (‘style’, $_POST[‘set’], time()+31536000, ‘/’, ‘dreamwhisperdesigns.com’, ‘0’);
header(“location: ” . $_SERVER[‘HTTP_REFERER’]);
}
?>
´
header.php
´
<link rel=”stylesheet” type=”text/css” media=”screen” title=”Pegasus” href=”<?php bloginfo(‘template_directory’); ?>/<?php echo (!$_COOKIE[‘style’])?’Pegasus’:$_COOKIE[‘style’] ?>.css” />
<link rel=”stylesheet” type=”text/css” media=”screen” title=”Spring” href=”<?php bloginfo(‘template_directory’); ?>/style.css” />
´
I’ve tried everything – full urls, different combinations, etc.
´
<link rel=”stylesheet” type=”text/css” media=”screen” title=”Spring” href=”<?php echo (!$_COOKIE[‘sitestyle’])?’style’:$_COOKIE[‘sitestyle’] ?>.css” />
´
What am I missing?