Hey everyone, I have come to something I am working on for my website template. I have a top navigation that are tabs and when you click a tab to the next page it pops out the next tab as the selected tab. Very basic with HTML this is my sample code for it.
<!-- **** INSERT NAVIGATION ITEMS HERE (use id="selected" to identify the page you're on **** -->
<li><a id="selected" href="index.php">home</a></li>
<li><a target="_blank" href="/blog">blog</a></li>
Note: The files do have a .php file extension but I have very little php in the files the site in mostly HTML.
so for example if I click portfolio. it would take me to porfolio.php but the portfolio tab in the nav would have the selected id? I might have understood wrong, but that is always a high possibility this early.
to keep it as you have it now. I would just use something like:
It's really not all that hard (at least compared to some things). There are a number of ways. One easy(?) way is to define a function that accepts an argument to indicate which one is selected:
$tabs = array(
'Home' => '/index.php',
'About Us' => '/about/index.php',
'Contact Us' => '/contact/index.php'
echo "<ul id='tabs'>";
foreach($tabs as $label => $path)
if($label == $active)
echo "<li class='active'>$label</li>\n";
echo "<li><a href='$path'>$label</a></li>\n";
Then in your pages:
rest of page...