Add classes to menu item based on url For various reasons, I can not use the Drupal 7 menu system and have to hardcode a special menu. I am trying to add an active class basing on the URL. I was looking at this page and trying the following. 

        &lt;ul class="nav navbar-nav"&gt;
            &lt;li&gt;&lt;span class="icon-search"&gt;&lt;/span&gt;&lt;a href="/search" title="" class="&lt;?php if ( ($path == $_GET['q'] || ($path == '/search') ) ) : print ('active');endif;?&gt;"&gt;Search&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;span class="icon-sports"&gt;&lt;a href="/sports" title=""&gt;sports&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;span class="icon-news"&gt;&lt;a href="/news/" title=""&gt;news&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;span class="icon-ent"&gt;&lt;a href="/entertainment" title=""&gt;entertainment&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
You can read URL with out base path using $_GET['q'] ..

&lt;?php if ( $_GET['q'] == "search" ) : print ('active'); endif; ?&gt;


OR 

You can use current_path API function which does the same...