Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

Categories

In this Discussion

Who's Online 18

6apxatCurtisOdenTinoHartungericgilletteestlortabacmatt +11 guests

Not sure how to say this but I'll try.

How do you get it so nav links will be highlighted when your viewing the page it's linked to. Just like the way it works on vanilla forums up top.
«1

Comments

  • BenBen
    Posts: 534
    You assign an extra class to the link that relates to that page. With the vanilla tabs, all the links have class="TabOff" except the active one, which is defined by class="TabOn" this means that, that specific tab can be given extra styling.
  • I suppose I won't be able to do that if I'm calling information into an index page with a php command?
  • BenBen
    Posts: 534
    like... index.php?page=blahdeblah type thing?

    You'd just need to set up a little If statement for each tab, like If the page equals 'news' then echo TabOn otherwise echo TabOff
  • well, I suppose I can show you the site and you can help determine the best route? If it's not too much hassle, that is. http://onemanshortproductions.com
  • bump?
  • you could set a body id on your pages if you want to do a pure css version. then in the css when the body id is present it will apply a different style e.g. <body id="home"> <a href="/" id="homeNav">home</a> then in the css put: #home #homeNav{ font-weight:bold; }
  • Posts: 1,433
    with regards to doing this with php, i'm not a programmer so turned to the wordpress coddex for a good tutorial on this: http://codex.wordpress.org/Dynamic_Menu_Highlighting
  • BenBen
    Posts: 534
    at timberford: doh, I should have thought of that one. So much easier than the PHP method!
  • glad to help. it's a handy technique, i use it all the time.
  • trouble with that is my php code just calls a page into the body... there is no seperate bodies... <body> <div id="wrapper"> <div id="banner"></div> <div id="nav"> <ul> <li><a href="?news" title="Home">Home</a></li> <li><a href="?aboutus" title="About Us">About Us</a></li> <li><a href="?currentprojects" title="Current Projects">Current Projects</a></li> <li><a href="?media"title ="Media">Media</a></li> </ul> </div> <div id="content"> <?php $query = $_SERVER['QUERY_STRING']; $query = explode(':',$query); if(empty($query[0]) && empty($query[1])) { include 'news.php'; } elseif(empty($query[1])) { include $query[0].'.php'; } else { include $query[0].'/'.$query[1].'.php'; } ?> </div>
  • so you're saying you use a single template for all your pages, regardless of their content?
  • yes
  • in that case you could use a statement that detects which page it is and inserts an id into the body and still use the css method i mentioned.
  • I'm total novice to php... how would I go about this?
  • Posts: 5,574
    well, on the basis that your pages are defined in a ?page=whatever statement, for your css if you use a body tag such as: <body id="<?php echo $_GET['page']; ?>"> Which should work. I think.
  • That doesn't work... It produces a blank id statement... I also tried useing echo $_SERVER['QUERY_STRING']; which didn't work... I'm not even sure what that would so anyway, lol... I posted the actual coding I use above... so if that can help you at all. Thanks for being helpful. my pages arent ?page=whatever they are ?whatever
  • Posts: 5,574
    um? I'm not sure that'l work. Though i'm probably wrong. As far as i know it needs to be ?variablename=variablecontent
  • It does work.... http://onemanshortproductions.com is a working example of it. http://onemanshortproductions.com/?news http://onemanshortproductions.com/?opportunities etc... Or are you saying you don't know how to get it to echo the page when it's in that form?
  • Posts: 5,574
    Isnt that your site? How do you get it to work out what page to load up then?
  • I have an index page that is designed the way I want... in the body tag I insert the php command I posted 10 posts up... I have individual php files that it calls into the body of the index page. When I click on say Opportunities link the href="?opportunities" it then calls opportunities.php into the body.
  • Posts: 5,574
    Yeah. That'l teach me to half read discussions :) In that case, assuming its in the same file, you can use: Unless its in a different file or above where query is set, in which case you can use: <?php $query = $_SERVER['QUERY_STRING']; $query = explode(':',$query); ?> <body id="<?php echo $query[0]; ?>"> And then remove the definition of query lower down.
  • Didn't work... I tried $query[1] as well, didn't work. I tried $query... and that made it body id="Array"... which is wrong too...
  • Don't mean to be a pest, but does anyone got any ideas?
  • Posts: 926
    Was bored so I fiddled for a little bit with this. This is what I got http://hatethis.org/temp/tabs.txt Its nothing fancy, but it worked with the way you are calling pages.
  • Thank you kindly, that worked....
  • Posts: 5,574
    sorry Mr F. i read this with the intention of replying then had to shoot out to work and forgot about it. We really need that 'mark as unread' thing goin on.
  • It's ok. Thanks for your help. You guys are awesome.
  • I must be a right prick, but... Is there a way I can have Home to be TabOn when you first enter the page... the page loads as http://onemanshortproductions.com but it's the same as http://onemanshortproductions.com/?news I tried adding or "index.php" to the php statement for home but that keeps it on forever. I want it Home to be tabbed on when there is no ? and when it's on ?news. If this is not possible, just let me know
  • Posts: 5,574
    Just a guess, but give this a go...change: if($_SERVER['QUERY_STRING'] == 'news') to: if($_SERVER['QUERY_STRING'] == 'news' || !$_SERVER['QUERY_STRING'])
  • Posts: 926
    Yup, just tested that mini, worked for me.
This discussion has been closed.