How to use class="Active" in navigation, If you are using static pages?

navigation with URL
My Local Project for Getacho Company
I am working on my own company project. I am using Pixelogic static theme. I created different files for different website parts. like
  1. Menu.php
  2. Header.php
  3. Footer.php
Like it. But here I was facing a problem in class="active" Code. It was like

 <nav class="navigation">  
   <ul class="sf-menu" style="float:left;">  
     <li class="active"><a href="index.php">Home</a>  
     </li>  
     <li><a href="about.php">About</a></li>  
     <li><a href="portfolio.php">Portfolio</a>  
     <li><a href="forums/">Forums</a>  
     </li>  
     <li><a href="blog/">Blog</a>  
     </li>  
     <li><a href="contact.php">Contact</a>  
       <ul class="sub-menu main-ul">  
       <li><a href="support/">Support</a></li>  
       <li><a href="support/">Live Chat</a></li>  
       </ul>  
     </li>  
     <li><a href="user/">User Panel</a>  
       <ul class="sub-menu main-ul">  
       <li><a href="user/seo/">SEO Panel</a></li>  
       </ul>  
     </li>  
   </ul>  
 </nav>  

But here I was getting some problem that how to move class="active" according to static current page.
Then I consulted with my friends and someone suggested me a code. now it is working.

Code was :

 <?php  
      $url = $_SERVER['REQUEST_URI'];  
      if (strpos($url,'about.php') !== false)  
           echo 'class="active"';  
 ?>  

Here you need to understand STRPOS function.
I used same code in my navigation. Now navigation is working good. Now navigation code is

 <div id="menu" class="clearfix">  
   <nav class="navigation">  
     <ul class="sf-menu" style="float:left;">  
       <li   
       <?php   
       $url = $_SERVER['REQUEST_URI'];  
       if (strpos($url,'index.php') !== false)  
       {  
       echo 'class="active"';  
       }  
       ?>  
       ><a href="index.php">Home</a>  
       </li>  
       <li   
       <?php   
       $url = $_SERVER['REQUEST_URI'];  
       if (strpos($url,'about.php') !== false)  
       {  
       echo 'class="active"';  
       }  
       ?>  
       ><a href="about.php">About</a></li>  
       <li   
       <?php   
       $url = $_SERVER['REQUEST_URI'];  
       if (strpos($url,'portfolio.php') !== false)  
       {  
       echo 'class="active"';  
       }  
       ?>  
       ><a href="portfolio.php">Portfolio</a>  
       <li><a href="forums/">Forums</a>  
       </li>  
       <li><a href="blog/">Blog</a>  
       </li>  
       <li   
       <?php   
       $url = $_SERVER['REQUEST_URI'];  
       if (strpos($url,'contact.php') !== false)  
       {  
       echo 'class="active"';  
       }  
       ?>  
       ><a href="contact.php">Contact</a>  
         <ul class="sub-menu main-ul">  
         <li><a href="support/">Support</a></li>  
         <li><a href="support/">Live Chat</a></li>  
         </ul>  
       </li>  
       <li><a href="user/">User Panel</a>  
         <ul class="sub-menu main-ul">  
         <li><a href="user/seo/">SEO Panel</a></li>  
         </ul>  
       </li>  
     </ul>  
   </nav>  
 </div>  

Guidance by :  Nahyan Shiwani

+ comments + 4 comments

Anonymous
February 4, 2014 at 8:14 PM

I like the helpful info you provide in your articles.
I will bookmark your weblog and check again here frequently.

I am quite sure I will learn lots of new stuff right here!
Best of luck for the next!

Also visit my page; schwindel übelkeit ()

February 5, 2014 at 8:49 PM

Thanks friend for it. I welcome you.
Samee Ullah Feroz

Anonymous
February 6, 2014 at 3:32 PM

you're in point of fact a excellent webmaster. The web site loading speed is incredible.
It sort of feels that you are doing any unique trick.
Moreover, The contents are masterwork. you have performed a fantastic
process in this matter!

Here is my blog übelkeit ()

February 6, 2014 at 7:48 PM

Thanks. I am not using any trick for website speed. It is Blogger magic. My website is hosted on Blogger. thanks for it.

Post a Comment

Give your reviews about this blog. Leave your comments. What do you think about this post?

Comments Guidelines:

1) I love to read comments, but please avoid spam.

2) Like this blog, share your insights, and spread the word.

3) You can use basic HTML/xHTML tags.

4) All comments are DoFollow—please use the section professionally.

5) Kindly mention your name or brand below your comment.

6) Constructive suggestions for improvement are always welcome.


Thanks for visiting Samee Articles.

========================================

Best Regards,

Samee U. Feroz

 
Copyright © 2011-2026. Samee Articles - All Rights Reserved
Proudly powered by Blogger