Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Current Nav Highlighting using php to set the body ID

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29074
    mpoisel
    Member

    I been building a custom theme in WordPress and was trying to get the Current nav Highlighting from podcast #36 to work.

    This is the html:



    $page = $_SERVER;
    $page = str_replace("/","",$page);
    $page = str_replace(".php","",$page);
    $page = str_replace("?s=","",$page);
    $page = $page ? $page : 'default'
    ?>

    This is the css:


    .nav-wrap {width:984px; height:30px; float:left; margin-top:170px;}
    ul#nav1 {width:376px; height:30px; float:left; list-style:none; padding-left:22px; margin:0;}
    ul#nav1 li {list-style:none outside none; display:inline; line-height:30px;}
    ul#nav1 li a {font-family:"Times New Roman", Times, serif; font-size:18px; color:#e6d7c5; text-decoration:none; font-weight:bold; margin-left:35px;}
    ul#nav1 li a:hover {color:#3c1b25; text-decoration:none;}

    body#home ul#nav1 li.home a,
    body#events-calender ul#nav1 li.events a,
    body#menu ul#nav1 li.menu a,
    body#gallery ul#nav2 li.gallery a,
    body#contact ul#nav2 li.contact a {color:#3c1b25; text-decoration:none;}


    ul#nav2 {width:376px; height:30px; float:right; list-style:none; padding:0; margin-left:-22px;}
    ul#nav2 li {list-style:none outside none; display:inline; line-height:30px;}
    ul#nav2 li a {font-family:"Times New Roman", Times, serif; font-size:18px; color:#e6d7c5; text-decoration:none; font-weight:bold; margin-left:35px;}
    ul#nav2 a:hover {color:#3c1b25; text-decoration:none;}

    I’ve watched the tutorial several times checking my code and it still isn’t highlighted. When I checked it in firebug it is pulling in the url as the body id. But, I also noticed it was pulling in all the sub directories into the body id because I have wordpress installed in a sub directory. Now knowing that I changed the the code to look like this:

    html:



    $page = $_SERVER;
    $page = str_replace("/","",$page);
    $page = str_replace(".php","",$page);
    $page = str_replace("?s=","",$page);
    $page = $page ? $page : 'default'
    ?>

    css:


    .nav-wrap {width:984px; height:30px; float:left; margin-top:170px;}
    /*.left-menu {width:376px; height:30px; float:left;}*/
    ul#nav1 {width:376px; height:30px; float:left; list-style:none; padding-left:22px; margin:0;}
    ul#nav1 li {list-style:none outside none; display:inline; line-height:30px;}
    ul#nav1 li a {font-family:"Times New Roman", Times, serif; font-size:18px; color:#e6d7c5; text-decoration:none; font-weight:bold; margin-left:35px;}
    ul#nav1 li a:hover {color:#3c1b25; text-decoration:none;}

    body#staginggypsystag ul#nav1 li.home a,
    body#staginggypsystagevents-calender ul#nav1 li.events a,
    body#staginggypsystagmenu ul#nav1 li.menu a,
    body#staginggypsystaggallery ul#nav2 li.gallery a,
    body#staginggypsystagcontact ul#nav2 li.contact a {color:#3c1b25; text-decoration:none;}

    /*.right-menu {width:376px; height:30px; float:right;}*/
    ul#nav2 {width:376px; height:30px; float:right; list-style:none; padding:0; margin-left:-22px;}
    ul#nav2 li {list-style:none outside none; display:inline; line-height:30px;}
    ul#nav2 li a {font-family:"Times New Roman", Times, serif; font-size:18px; color:#e6d7c5; text-decoration:none; font-weight:bold; margin-left:35px;}
    ul#nav2 a:hover {color:#3c1b25; text-decoration:none;}

    It still isn’t working and I’m not sure what I’m doing wrong. If anyone can be of any help I would really appreciate it.
    here is a current link to the testing site: http://www.mainlineserver.com/staging/gypsystag/

    Thanks
    Mike

    #76776
    heysep
    Member

    i think this is actually a css issue not a php one, since your body ids are correct. try putting the body-id-specific style definitions at the bottom of your css. i think you basically overwrite them later in your css file.

    #76777
    mpoisel
    Member

    I’m not sure if I follow you. can you please clarify?

    #76778
    heysep
    Member

    1.) your in the wrong forum, ask the css nerds ;-) your body ids are generated as they should ()
    2.) there i was wrong ;-)
    your li class names in the css don’t match :


  • &
    body#staginggypsystagmenu ul#nav1 li.menu a, ?
  • should be

    body#staginggypsystagmenu ul#nav1 li.staginggypsystagmenu a,

    i guess

    #76779
    mpoisel
    Member

    Thanks it works now. I totally missed that.
    Sorry for posting in the wrong forum.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.