Jump to content

menu help


chrismarsden

Recommended Posts

Ok just a bit of menu help, i want to basicly show a static active image on a link when you on a page but i have the menu in an include so obviously if i set that static to home the hover over that happens on the other pages will work but no matter what page im on it will show the main page as the page your on.

      <div class="menu">
        <ul>
           <li class="active"><a href="index.php"><b>Home</a></li>
          <li><a href="">Services</a></li>
          <li><a href="about.php">About Us</a></li>
          <li><a href="">Portfolio</a></li>
          <li><a href="">Contact Us</a></li>
        </ul>
      </div>

 

basicly if im on the about page i want the active to move aswell.... any ideas?

 

Link to comment
https://forums.phpfreaks.com/topic/203243-menu-help/
Share on other sites

<?php
$referer = basename($_SERVER['SCRIPT_NAME']);
?>
      <div class="menu">
        <ul>
           <li <?php if ($referer == 'index.php') { echo 'class="active"'; } ?>><a href="index.php"><b>Home</a></li>
          <li <?php if ($referer == 'services.php') { echo 'class="active"'; } ?>><a href="">Services</a></li>
          <li <?php if ($referer == 'about.php') { echo 'class="active"'; } ?>><a href="about.php">About Us</a></li>
          <li <?php if ($referer == 'portfolio.php') { echo 'class="active"'; } ?>><a href="">Portfolio</a></li>
          <li <?php if ($referer == 'contact.php') { echo 'class="active"'; } ?>><a href="">Contact Us</a></li>
        </ul>
      </div>

 

Something similar to that :)

Link to comment
https://forums.phpfreaks.com/topic/203243-menu-help/#findComment-1064879
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.