• I’ve borrowed some code from this support forum so that I can generate an inline CSS style for the specific page a person is on. The navigation button is highlighted depending on what page of the site you’re on. I use this code to style the specific list element using inline CSS:

    <?php
    if ( is_home() ) { $current = 'b-home a'; }
    elseif ( is_page('about') ) { $current = 'b-abou a'; }
    elseif ( is_page('about-the-author') ) { $current = 'b-abou a'; }
    elseif ( is_page('about-the-site') ) { $current = 'b-abou a'; }
    elseif ( is_page('brief-resume') ) { $current = 'b-abou a'; }
    elseif ( is_page('archive-index') ) { $current = 'b-arch a'; }
    elseif ( is_page('links') ) { $current = 'b-link a'; }
    elseif ( is_page('contact') ) { $current = 'b-cont a'; }
    ?>

    <style type="text/css">
    li#<?php echo $current; ?> {
    color: #fff;
    font-weight: bold;
    background: #62C061 url(/img/nav-focus.gif) repeat-x bottom left;
    }
    </style>

    As im no expert on PHP what and where do I add to this code to style my list elements if $current is none of these options/pages. eg. a comment page? I dont want any of my navigation buttons highlighted on most of the other pages so the site actually works correctly as it is – the only problem is it wont validate. Basically that means i only need the inline CSS on my main web pages.

    Hope that makes sense to someone! Thanks in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Humm.. not to me unfortunately.
    Could you provide us with some working example and with a page where it does not do what you want it to do ?
    I’m the kind of visual guy 😉

    Post a link to your site, and then perhaps someone can look at the validation for you and offer a better answer.

    Thread Starter endpeg

    (@endpeg)

    The website’s at:
    http://www.endpeg.com/

    Home, About, Archives etc are all highlighted when you’re on those pages. I just need a ‘catch all’ piece of code for the rest of the pages that dont get highlighted.

    Thread Starter endpeg

    (@endpeg)

    Anybody?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP generated inline CSS query’ is closed to new replies.