Subscribe To Our Newsletter

Sign Up Now To Get Free Coupon Codes, Event Coupon Codes Updates, Offers Updates. It's 100% Free!

We Hate Spam! Really, It's terrible and we never do it.

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
Share this article :

+ comments + 4 comments

Anonymous
February 4, 2014 at 10:14 AM

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 10:49 AM

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

Anonymous
February 6, 2014 at 5:32 AM

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 9:48 AM

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?

Meet Samee Ullah Feroz On Google Plus
Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe Samee Articles blog.

---------------------------------------
Thanks for visiting QWC.Me.
==========================================
For free guidelines contact me on SEO Expert | Samee Ullah Feroz is online there.
==========================================
Best Regards

 
Support : | Internet Marketing Specialist And Business Developer
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger