WordPress.org

Forums

Switching Stylesheets - HELP (4 posts)

  1. Anonymous
    Unregistered
    Posted 10 years ago #

    Hey there, new-ish user here, using 1.0.2.
    I wanted to add a couple of links to my menu to pass a variable to PHP which would determine which stylesheet would load and then also cookie that value to keep it between sessions...
    However it doesn't work so far and I thought I cry and ask for help... The page loads but the stylesheet selected doesn't so you end up with unstyled content.
    Here is what I've done so far:
    At the very top of the page I put the cookie stuff:
    if ($sheetvar){
    setcookie ("StyleCookie", $sheetvar);
    } else if ($_COOKIE['StyleCookie']){
    $sheetvar = $_COOKIE['StyleCookie'];
    }else {
    $sheetvar = "standard-sans";
    }

    Then in the header I commented out the style sheet line and added...
    <?php
    switch ($sheetvar){
    case "standard-sans":
    print ("<style type=\"text/css\" media=\"screen\">
    @import url(\"$siteurl/wp-layout.css\")
    </style>");
    break;
    case "standard-sans2":
    print ("<style type=\"text/css\" media=\"screen\">
    @import url(\"$siteurl/wp-layout-ss2.css\")
    </style>");
    break;
    default:
    print ("<style type=\"text/css\" media=\"screen\">
    @import url(\"$siteurl/wp-layout.css\")
    </style>");
    break;
    }
    ?>

    And lastly in the menu code I put in this:
    <li id="other">


  2. Can anyone assist?
    The URL for the blog is http://bookofgeek.robstearn.com

  • Mark (podz)
    Support Maven
    Posted 10 years ago #

    Have you tried the styleswitcher by Alex ?
    http://ten-sixteen.net/tutorials/styleswitcher.txt

  • carthik
    Inactive
    Posted 10 years ago #

    sadish, that information will be useful to someone else later too. Can you please add that to the http://wiki.wordpress.org - wiki?

  • Anonymous
    Unregistered
    Posted 10 years ago #

    Thanks for the tips guys.
    I'll go away and pay with them and report back if I get any problems....
    While I'm at it, I had an idea that may have been done but should there be an online index of WordPress users blogs, listed with some metadata so we programatically build a list of links on our sites filtered to be relevant to us.

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags

    No tags yet.