• Hello.

    I’m fairly comfortable with creating HTML pages, but CSS and PHP are both new concepts to me. I’m seriously feeling out of my depth at the moment, so I’m throwing myself on the mercy of this good community. (At this point I’m not even sure if I can do what I’m trying to do.)

    Although the solution to my problem may be convoluted, my goal is straightforward enough: I want to add a graphic navigation bar with rollover interactivity to the sidebar of the WordPress page I’m working on.

    My Approach:
    I’ve added an HTML table to the “sidebar.php” page of my WP site, which uses the usual “onmouseover” swap for a different GIF image for the nav button. I’ve added the javascript function for the image swap and the preloadImages function to my “header.php” page. Currently, the “normal” state of the buttons on my navbar is loading properly, but I can’t get my rollover images to work.

    Q: Is javascript able to function if it’s spread out through PHP like this?

    Any and all help, guidance and direction are greatly appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • well for starters, you don’t need the table setup OR javascript to do this… it can be done entirely in CSS

    i’d scrap the idea of tables, as well as the javascript.

    here’s an EXAMPLE of css for “button-type” navigation… you’re going to definitely have to tweak it to relate to your theme and everything, but this will get you started…

    #sidebar a, a:visited {
    border:1px solid #c00000;
    background:#ffffff url(images/button1.jpg);
    color:#FFD5D5;
    display:block;
    padding:3px 10px 5px;
    text-transform:uppercase;
    }

    #sidebar a:hover {
    border:1px solid #c00000;
    background:#ffffff url(images/button2.jpg);
    color:#FFD5D5;
    display:block;
    padding:3px 10px 5px;
    text-transform:uppercase;
    }

    “button1.jpg” would be your “normal state” of the button and “button2.jpg” would be the “hover state” of the button. make sure you include the correct file path to get to the buttons… they should be in the images folder inside your theme.

    NOTE: There are additional ways to accomplish this, with “boxes” – but it’s a little more complicated (not much, just a teeny bit) – try this one first, and let us know if it works for you.

    Another NOTE: When you’re calling this in to your sidebar, you’d use <div id="sidebar"> and then end the div with </div>

    Thread Starter Zacurtjadi

    (@zacurtjadi)

    Thank you.

    Well, I’m not really comfortable with CSS but I’m ready to learn. If we’re going to go for this we might as well go all the way.

    My page is located at https://fuelwerks.dreamhosters.com/

    I’ve cleared all of the aforementioned Javascript and HTML out of my sidebar, and I’ve added the code to my CSS file. I’m getting a rollover effect, but it looks like my graphic is now appearing everywhere there’s a link.

    For what it’s worth, I think I’d like to do this with boxes. (Containers?) I’m going to have to deal with some positioning issues.

    Thread Starter Zacurtjadi

    (@zacurtjadi)

    Forging ahead…

    I’ve created a container for my graphic elements and I’ve positioned it in the sidebar. I’m still not sure how to place my graphics for the rollover effect. (I’m not sure if I really want text for the rollover.)

    I still need help, but I’m scouring the internet and some books for more information. All assistance is appreciated…

    Chaz

    (@eternalskychaz)

    Don’t forget that IE does not support the hover pseudo-class and so rolover images via CSS will not function. There are Javascript routines that are used by the Suckerfish dropdown menu that will give you a very good work around for this.

    In no event will any of this work in anything before IE6, though.

    I am sorry that I don’t have the links to hand, but you can search this forum or the ‘net at large for “Suckerfish” and examine the JS coding in combination with CSS commands to see how you might hack their code for your purposes.

    To directly answer your question, Zacurtjadi, no WordPress does not seem to support Javascript behaviors for rollover buttons or dropdown menus. I’ve tried to get them to work on the WordPress portion of my site and have had no success whatsoever; something about splitting the code up between the header and body files seems to break the JS.

    If you have success with hacking Suckerfish, please let me know as I am very interested in creating an alternative form of navigation for my site.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding Navbar to “Sidebar.php”’ is closed to new replies.