Thread: php tab select
View Single Post
Old 07-06-2011, 02:28 PM   #2 (permalink)
tony
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

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:

PHP Code:
<?php
$page 
basename(__FILE__);
$sel 'id="selected"';
?>
<ul>
  <!-- **** INSERT NAVIGATION ITEMS HERE (use id="selected" to identify the page you're on **** -->
  <li><a <?php if($page == 'index.php'){ echo $sel; } ?> href="index.php">home</a></li>
  <li><a <?php if($page == 'about.php'){ echo $sel; } ?>  href="about.php">about</a></li>
  <li><a <?php if($page == 'portfolio.php'){ echo $sel; } ?>  href="portfolio.php">portfolio</a></li>
  <li><a <?php if($page == 'services.php'){ echo $sel; } ?>  href="services.php">services</a></li>
  <li><a <?php if($page == 'contact.php'){ echo $sel; } ?>  href="contact.php">contact</a></li>
  <li><a target="_blank" href="/blog">blog</a></li>
</ul>
a bit repetitive, but it works
tony is offline  
Reply With Quote