WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP Stylesheet Switcher from A List Apart Not Working with WordPress (5 posts)

  1. christophdollis
    Member
    Posted 6 years ago #

    Hello!

    I am using the PHP stylesheet switcher from A List Apart.

    It works with my hand coded static pages beautifully, but does not work with Word Press dynamic pages.

    Another member (CtiaKitahara) said this issue was resolved and came back to tell everyone how happy s/he was that they found the answer... but do you think they shared the answer? Or said where they found it?

    You know the answer!

    Can anyone help me resolve this?

    Thanks!

    Christoph

  2. christophdollis
    Member
    Posted 6 years ago #

    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

  3. benmillett
    Member
    Posted 6 years ago #

    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

  4. kentfallman
    Member
    Posted 6 years ago #

    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" />
    ´

  5. dreamwhisper
    Member
    Posted 6 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic