• Resolved thindery

    (@thindery)


    I have integrated bbpress into my studiopress theme located at:

    https://mipages.net/forum/

    everything works great except for the nav links active page at the top. the “home” link is acting like it is the current page when viewing the forum. Here is the code I am using for the tabs and to get the “forum” tab to generate the current page class when users are viewing the forum and other pages within the mipages.net/forum directory…

    <?
    $a = $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $b = "mipages.net/forum";
    
    if (is_home()) {
      $addclass = ' class="current_page"';
      } else {
      $addclass = '';
      }
    echo "<li" . $addclass . "><a title='Home'><span>Home</span></a>";
    
    if ($a == $b) {
      $addclass = ' class="current_page"';
      } else {
      $addclass = '';
      }
    echo "<li" . $addclass . "><a title='Forum'><span>Forum</span></a>";
    
    echo list_all_pages();?>

    the $a == $b check works perfectly (if you click other links you will see how the forum won’t keep the current page class. but for some reason the home tab will stay as the current page when viewing the forum pages, though it does it for nothing else..

    Anyone know what I am doing wrong here?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Maybe try something more like this?

    <?
    $WeAreHere = $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $TheForum = "mipages.net/forum";
    $TheHome = "mipages.net/";
    if ($WeAreHere == $TheHome) {
      $HomeClass = ' class="current_page"';
    } elseif($WeAreHere == $ TheForum){
      $ForumClass = ' class="current_page"';
    }
    
    echo "<li" . $HomeClass . "><a title='Home'><span>Home</span></a>";
    echo "<li" . $ForumClass . "><a title='Forum'><span>Forum</span></a>";
    
    echo list_all_pages();?>
    Thread Starter thindery

    (@thindery)

    i just wanted to post the resolution that i came up with incase anyone else can use it some time. I attempted your suggesting and it solved the problem of not hiliting “home” when viewing the forums. But since all my pages are like: https://mipages.net/?page_id=167 it hilites the home on those pages aswell..

    so.. this may be a little messy but it works:

    <?php
    $a = $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $b = "mipages.net/forum";
    $c = "mipages.net/";
    
    if (is_home() and $a == $b) {
      $addclass = '';
      } elseif (is_home()) {
        $addclass = ' class="current_page"';
      } else {
      $addclass = '';
      }
    echo "<li" . $addclass . "><a href='" . get_option('home') . "/' title='Home'><span>Home</span></a>";
    
    if ($a == $b) {
      $addclass = ' class="current_page"';
      } else {
      $addclass = '';
      }
    echo "<li" . $addclass . "><a href='" . get_option('forum') . "/' title='Forum'><span>Forum</span></a></li>";
    
    echo list_all_pages();?>

    for some reason the is_home() function recognized site.com/forum/ as the home page too, so I just put in a check that if it passed the is_home() check and $a == $b then it was defenitely a forum and don’t make the home tab current!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘home tab is hilighted when it shouldn’t’ is closed to new replies.