HTML selection

Proximity

IDK?
Feb 13, 2014
673
56
How can I use this

Code:
  <!--menu starts-->
  <div class="span8">
  <div id="smoothmenu" class="ddsmoothmenu">
  <ul>
  <li><a href="index.php" class="selected">Home</a></li>
  <li><a href="#">DDoS Protected VPS</a>
  <ul>
  <li><a href="Europe-OpenVZ-Linux-VPS.php"> Europe OpenVZ Linux VPS</a> </li>
  <li><a href="Europe-KVM-Linux-VPS.php"> Europe KVM Linux VPS</a> </li>
  <li><a href="Europe-KVM-Windows-VPS.php"> Europe KVM Windows VPS</a> </li>
   
  </ul>
  </li>
  <li><a href="#">Services</a>
  <ul>
  <li><a href="HTTP-Reverse-Proxies.php">HTTP Reverse Proxies</a> </li>
  <li><a href="TCP-Reverse-Proxies.php">TCP Reverse Proxies</a> </li>
  <li><a href="Cpanel-Protected-Web-Hosting.php">Protected Web Hosting</a> </li>
  <li><a href="Minecraft-DDoS-Protection.php">Minecraft DDoS Protection</a> </li>
  <li><a href="DDoS Protected-Dedicated-Servers.php">Protected Dedicated Servers</a> </li>
  </ul>
  <li><a href="aboutus.php">About</a></li>
  <li><a href="contact.php">Contact Us</a> </li>
     
  </ul>
  </div>
  <a href="clientarea.php" class="mybtn">Client Area</a> </div>
  <!--menu ends-->

in a navi.php

and <?php require_once 'navi.php' ?>

but still have the page I am on highlighted like so:

a33b7325f7263a8e0fa561914e7684e4.png
 

Khalil

IDK
Dec 6, 2011
1,642
786
There is an easy way around this, you can give each page a certain ID, for example for the home page: <?php $pid = 1; ?>, and in the navigator, you'd do:
<li><a href="index.php" <?php if($pid == 1) { echo'class="selected"'; } ?>>Home</a></li>, and so on with the other pages..
 

TesoMayn

Boredom, it vexes me.
Oct 30, 2011
1,482
1,482
Just so I can get credit, I'm going to steal from Khalil's idea

Put this at the top of the page
Code:
<?php
$uri = $_SERVER['REQUEST_URI'];
$path = parse_url($uri, PHP_URL_PATH);
$explosion = explode('/', $path);
$page = $explosion[1];?>
?>

Then add this to each menu link
Code:
class="<?php if($page=="PAGENAME"){echo "selected";}?>"
 

Proximity

IDK?
Feb 13, 2014
673
56
Add
<?php
$uri = $_SERVER['REQUEST_URI'];
$path = parse_url($uri, PHP_URL_PATH);
$explosion = explode('/', $path);
$page = $explosion[1];?>
?>

to every page and then
class="<?php if($page=="PAGENAME"){echo "selected";}?>" in the navi.php?
 
Add
<?php
$uri = $_SERVER['REQUEST_URI'];
$path = parse_url($uri, PHP_URL_PATH);
$explosion = explode('/', $path);
$page = $explosion[1];?>
?>

to every page and then
class="<?php if($page=="PAGENAME"){echo "selected";}?>" in the navi.php?
 

Proximity

IDK?
Feb 13, 2014
673
56
This
Code:
<?php
$uri = $_SERVER['REQUEST_URI'];
$path = parse_url($uri, PHP_URL_PATH);
$explosion = explode('/', $path);
$page = $explosion[1];
?>

  <!--menu starts-->
  <div class="span8">
  <div id="smoothmenu" class="ddsmoothmenu">
  <ul>
  <li><a href="index.php" class="<?php if($page=="Home"){echo "selected";}?>">Home</a></li>
  <li><a href="#">DDoS Protected VPS</a>
  <ul>
  <li><a href="Europe-OpenVZ-Linux-VPS.php" class="<?php if($page=="Europe OpenVZ Linux VPS"){echo "selected";}?>"> Europe OpenVZ Linux VPS</a> </li>
  <li><a href="Europe-KVM-Linux-VPS.php" class="<?php if($page=="Europe KVM Linux VPS"){echo "selected";}?>"> Europe KVM Linux VPS</a> </li>
  <li><a href="Europe-KVM-Windows-VPS.php" class="<?php if($page=="Europe KVM Windows VPS"){echo "selected";}?>" > Europe KVM Windows VPS</a> </li>
   
  </ul>
  </li>
  <li><a href="#">Services</a>
  <ul>
  <li><a href="HTTP-Reverse-Proxies.php" class="<?php if($page=="HTTP Reverse Proxies"){echo "selected";}?>">HTTP Reverse Proxies</a> </li>
  <li><a href="TCP-Reverse-Proxies.php" class="<?php if($page=="TCP Reverse Proxies"){echo "selected";}?>">TCP Reverse Proxies</a> </li>
  <li><a href="Cpanel-Protected-Web-Hosting.php" class="<?php if($page=="Protected Web Hosting"){echo "selected";}?>">Protected Web Hosting</a> </li>
  <li><a href="Minecraft-DDoS-Protection.php" class="<?php if($page=="Minecraft DDoS Protection"){echo "selected";}?>">Minecraft DDoS Protection</a> </li>
  <li><a href="DDoS Protected-Dedicated-Servers.php" class="<?php if($page=="Protected Dedicated Servers"){echo "selected";}?>">Protected Dedicated Servers</a> </li>
  </ul>
  <li><a href="aboutus.php" class="<?php if($page=="About"){echo "selected";}?>">About</a></li>
  <li><a href="contact.php" class="<?php if($page=="Contact Us"){echo "selected";}?>">Contact Us</a> </li>
     
  </ul>
  </div>
  <a href="clientarea.php" class="mybtn">Client Area</a> </div>
  <!--menu ends-->

is my navi.php is this right?
 

Proximity

IDK?
Feb 13, 2014
673
56
I got it to work but

for
<li><a href="#">Services</a>

I need it to be like the others it selects it so

like

If on service page Dedicated server it highlights both and etc
 
Bump can anyone help me


So it highlights Services and the servce
 

Users who are viewing this thread

Top