WordPress.org

Support

Support » Themes and Templates » Blix: Little trouble with NavBar extra button

Blix: Little trouble with NavBar extra button

  • 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!

Viewing 15 replies - 1 through 15 (of 18 total)
  • 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

    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 🙁

    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.

    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>

    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!

    Hold on

    <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.

    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.

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

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

    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.

    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.

    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!

    Humm… Let me fix that one.

    Replace

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

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

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Blix: Little trouble with NavBar extra button’ is closed to new replies.
Skip to toolbar