• In case anyone is interested, I’ve hacked my installation of WordPress slightly to allow me to use multiple skins, and switch between them at will. I’m not a big php coder (yet?), and I’m still not familiar with the WordPress api, but the method is simple. I’m sure some of you would be able to tighten things up a bit.
    First of all, I added a new directory, wp-content/skins. Then for every skin I want, I add a subdirectory to the skins directory and put the index.php and any css in there. I had to remove the first 4 lines of each index.php (you know, the bit that says ‘don’t remove this’ ;). You’ll see why in a minute. Inside each skin’s index.php, I used the $skinurl variable to get at style sheets etc.
    E.g.
    <style type=”text/css” media=”screen”>
    @import url( <?php echo $skinurl; ?>/style.css );
    </style>
    I replaced my main wordpress/index.php with the following:
    <?php
    /* change this to “./some-other-dir/” if you’ve installed somewhere other than the default wordpress directory */
    $installdir = “./”;
    /* Don’t remove this line. */
    require($installdir.’wp-blog-header.php’);
    if (isset($skin))
    {
    setcookie(‘wp-skin’, $skin);
    }
    else
    {
    if (isset($_COOKIE[‘wp-skin’]))
    $skin = $_COOKIE[‘wp-skin’];
    else
    {
    $skin = “default”;
    setcookie(‘wp-skin’, $skin);
    }
    }
    $skinurl = get_settings(‘siteurl’).’/wp-content/skins/’.$skin.’/’;
    require($installdir.’wp-content/skins/’.$skin.’/index.php’);
    ?>
    So now I can switch between skins just by adding ‘?skin=whatever’ to my url. I’ve got a symbolic link named ‘default’ in wp-content/skins pointing to my default skin.
    If you want to see it working, visit https://www.stufftoread.net/ . You only really have 2 choices of skin: stufftoread, or wp-default, with the default symbolic link pointing at stufftoread. It could do with failing a bit more elegantly if the skin didn’t exist, but I’m not going to bother. The main purposes I would use this for would be for developing a new layout for the site without disturbing anyone else, and also to allow, perhaps, an alternative 2 column skin, or maybe an IE compatibility skin.
    Anyway, that’s my 10 pence worth. Thanks WordPress team for making it so bloody easy to do. I’ve just started using WP, and used to use PostNuke which was really quite tricky to deal with sometimes. WP is a breeze!
    Cheers,
    Dave.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter daveelcock

    (@daveelcock)

    I should have mentioned that that was WordPress 1.2. I have since upgraded to 1.5 and so the ?skin=whatever thing doesn’t work any more.

    As you know the new 1.5 has its own Theme manager inside it, you could still attach a basic Style switcher into your theme the way you did it before but doing one that would take advantage of the WP-Theme system would be a bit more tricky and would proberly require user to be logged into WP

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How I did multiple skins’ is closed to new replies.