WordPress.org

Ready to get started?Download WordPress

Forums

Blix: Little trouble with NavBar extra button (19 posts)

  1. Fer
    Member
    Posted 8 years ago #

    Hey guys! I'm modifing the Blix Theme in order to suit my needs and I'm having this problem: I want to use the wp-stats.php plugin and I want to show a link to that file in the NavBar. I had no problem to add a link to it on the navbar, but it doesn't get highlighted when clicked, so I did a very little php coding and now I have this problem, the button is always highlighted, the other buttons get highlighted when chosen and work right, but the Stats Button (that's how I called the link to the plugin) is always highlighted.

    This is what I have:

    <ul>
    <li<?php if (is_home()) echo " class='selected'"; ?>><a>">Home</a>
    <?php
    $pages = BX_get_pages();
    if ($pages) {
    foreach ($pages as $page) {
    $page_id = $page->ID;
    $page_title = $page->post_title;
    $page_name = $page->post_name;
    if ($page_name == "archives") {
    (is_page($page_id) || is_archive() || is_search() || is_single())?$selected = ' class="selected"':$selected='';
    echo "<li".$selected."><a>Archives</a>n";
    }
    elseif($page_name == "about") {
    (is_page($page_id))?$selected = ' class="selected"':$selected='';
    echo "<li".$selected."><a>About</a>n";
    }
    elseif ($page_name == "contact") {
    (is_page($page_id))?$selected = ' class="selected"':$selected='';
    echo "<li".$selected."><a>Contact</a>n";
    }
    elseif ($page_name == "about_short") {/*ignore*/}
    else {
    (is_page($page_id))?$selected = ' class="selected"':$selected='';
    echo "<li".$selected."><a>$page_title</a>n";
    }
    }
    }
    ?>
    <li<?php if ('http://example.com/tests/wp-stats.php') echo " class='selected'"; ?>><a href="http://example.com/wp-stats.php">Stats</a>
    </ul>

    I know I'm missing something to tell the code to not highlight the button if it's not the chosen one, and also, the home button is highlighted while viewing the stats page. I really suck with php, can any of you tell me how to fix this?

    I hope you can help me! :) Thank you very much!

  2. carnold
    Member
    Posted 8 years ago #

    I too am having this problem with other things i put in the header file. I am too am using blix. did you find out how to correct this? If so, please let me know. carnold 5 at nc dot rr dot com

  3. Fer
    Member
    Posted 8 years ago #

    Nope, I haven't been able to fix it... I know it's a very silly thing the one I have to do, but can't get to it :(

  4. carnold
    Member
    Posted 8 years ago #

    Do you mind if we exchange email addresses? This way, whoever gets theirs fixed, they can let the other know what they did to fix it.

  5. Direkt
    Member
    Posted 8 years ago #

    Use this code instead of your method, it should work. If it doesn't tell me.

    <li <?php if(__FILE__ == 'wp-stats.php') { echo 'class="selected"'; } ?> ><a href="http://example.com/wp-stats.php">Stats</a></li>

  6. carnold
    Member
    Posted 8 years ago #

    Thanks but it did not work for me. I tried it on my "photos" link. and used this code:
    <li <?php if(__FILE__ == 'wp-gallery2.php') { echo 'class="selected"'; } ?> >Photos
    Any other ideas? Thanks again!

  7. Direkt
    Member
    Posted 8 years ago #

    Hold on

  8. Direkt
    Member
    Posted 8 years ago #

    <li <?php if($_SERVER['SCRIPT_NAME'] == 'wp-stats') { echo 'class="selected"'; } ?> ><a href="http://example.com/wp-stats.php">Stats</a></li> Okay I forgot __FILE__ did the entire path, sorry about that.

  9. carnold
    Member
    Posted 8 years ago #

    I have no idea why this is not working. If you go here, then click on "photos", you will see the "home" button stays selected and "photos" does not select at all. even with the new code, it did not select.

  10. Direkt
    Member
    Posted 8 years ago #

    Huh... Make a copy of the file in the templates directory and name it code.phps so I can look over it, please.

  11. carnold
    Member
    Posted 8 years ago #

    Done. It is in the "themes" folder. How would you like me to get it to you?

  12. Direkt
    Member
    Posted 8 years ago #

    Don't worry, I'll get to it myself. Thanks, as soon as I figure this out, I'm making a guide on how to do this.

  13. Direkt
    Member
    Posted 8 years ago #

    Okay what you want to do is also put it from your root directory so like /wp-plugins/plugin.php instead of just the name.

  14. carnold
    Member
    Posted 8 years ago #

    That made the "photos" select but "home" is also selected (at the same time as "photos" being selected). How to overcome that? Thaks again for the help, DirekT!

  15. Direkt
    Member
    Posted 8 years ago #

    Humm... Let me fix that one.

  16. Direkt
    Member
    Posted 8 years ago #

    Replace

    <?php if (is_home()) echo "id='selected'"; ?>

    with
    if ($_SERVER['SCRIPT_NAME'] == '/index.php') echo "id='selected'";

  17. carnold
    Member
    Posted 8 years ago #

    That worked only now, when you click on "home" is does not stay selected. You The man!!

  18. Direkt
    Member
    Posted 8 years ago #

    Change that code back to:
    <?php if (is_home()) echo "id='selected'"; ?>

    Since I use something just like this on my own blog, I can't figure out why it's not working, the only thing different is that I use it in the <a> tag.

    Like this:

    <li><a <?php if (is_home()) echo "id='current'"; ?> href="<?php bloginfo('url'); ?>">Home</a></li>

    But you need to change all of the follow code to deal with that.

  19. Direkt
    Member
    Posted 8 years ago #

    If that doesn't fix it, I'm out of ideas, well for the moment.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags