• hi all, I’ve searched through all previous posts on this topic and still am making no progress with Alex’s style switcher. The symptom is the following: when I bring up my root page for my WP blog in my browser, in Mozilla 1.8, I see only the following text:
    @import url(
    (though when I view source I see all of the index.php code up to that point. It’s as though the index.php script choked on what came next, which is of course the following:
    @import url( <?php wp_stylesheet(); ?> );
    I suspect that the wp_stylesheet function call is not being recognized, so let’s look at my-hacks.php:
    <?php include(‘wp-style-switcher.php’); ?>
    Seems ok, and other hacks are working, so the file is being read.
    I checked file permissions on all files, and all seems well there.
    I can switch styles manually by changing the filename in index.php:
    @import url( <?php echo $siteurl; ?>/wp-layout.css );
    So, would anyone have any clues for me? I tried looking for southern-gal’s tutorial but her domain name seems to be no longer working.
    thanks
    S

Viewing 12 replies - 1 through 12 (of 12 total)
  • Just out of curiosity, do you have style tags around it? It should look like this:

    <style type="text/css" media="screen">
    @import url( <?php wp_stylesheet(); ?>);
    </style>

    At least that’s what mine looks like.
    TG

    Thread Starter Anonymous

    yep, I sure do have style tags around it. I wonder what else could be wrong?

    Make sure the hack has been included. That could be a ‘call to undefined function’ which just dies silently with error reporting off.

    I moved the tutorials. You can find them here.

    Thread Starter Anonymous

    Southerngal, thanks for the new tutorial location. I took a look at it, and followed it to the letter. Same result as previously: my blog page comes up (in Mozilla) showing only the following text:
    import url(
    This suggests to me that the wp_stylesheet() call is not being understood, even though in my Options I’ve enabled my-hacks.php and it works with another hack (acronymit). I can’t figure out why it won’t work.!
    However, I did get it working finally. Here’s how: I put the two lines that normally would go into my-hacks.php into index.php instead:
    require_once(‘wp-style-switcher.php’);
    wp_style_coookie();
    this means that I’m not able to use my-hacks.php, which could cause a problem if/when I upgrade. But at least I can change styles on the fly!

    midtaod, can you provide a link to your site? If you don’t mind, I’d like to take a look at it. See if I can spot anything.
    TG

    midtoad, move the style switcher code up or down in your my-hacks. I think that the acronymit can be lower. That may be the problem. Glad the tutorial helped. I moved it a few weeks ago and never updated the older threads, sorry about that! ??

    Thread Starter Anonymous

    TechGnome, my site is at:
    https://midtoad.homelinux.org/wp/
    Glad to have your once-over!
    S
    Southerngal, I’ll try your suggestion to move the style-switcher include somewhere else in the my-hacks.php file – though if it’s working now, I’m reluctant to break it! ??

    Thread Starter Anonymous

    “Coookie!!!”

    I was curious as to how mine was set up, since I’m also running acronymit….
    Here’s what I found:

    <?php
    require_once('wp-style-switcher.php');
    wp_style_cookie();
    include_once('wp-weather/weather.php');
    include_once('wp-includes/acronyms.php');
    add_filter('the_content', 'acronyms');
    add_filter('comment_text', 'acronyms');

    And thus begins my my-hask.php file.
    After thinking about it, what SouthernGal said about order being importaint is spot on. Here’s why. When the wp_style_cookie(); function is called, it determines if we are reading or setting the cookie. If the cokkie is to be set, it does it, then does a redirect, or changes the location of the current document (back to itself). In order for this to work, NOTHING can be sent to the browser. Nada, zip, zero, nothing. Which is why it should be the first lines of the my-hacks.php file. At that moment, nothing has been sent to the browser and so the cookie can be set safely.
    If it’s to read the cookie, it reads the contents, and stores the variable so that it can be used to set the proper style.
    It seems to work for you, kudos. But if you want to give it a try again, move the two lines back into my-hacks, and make sure they are the first two lines after the <?php tag.
    TG

    Thread Starter Anonymous

    got the style-switcher working with my-hacks.php! the problem was the following:
    Inside my-hacks.php, I was putting <?php and ?> around the require_once statement. this is, of course, unnecessary when you have those tags at the beginning and end of the file itself.
    After I removed the extraneous tags, the first headline of the newest post appeared, but no content. I realised that there was a problem with my acronyms filter, so it was taking $the_content and replacing it with nothing.
    thanks for all for your help!

    Glad you have it working!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Style switcher won’t work for me’ is closed to new replies.