Codeigniter--add “active” css class to link, how to?


Tags: php,css,codeigniter

Problem :

What's the quickest and easiest way to add the "active" class to a link, so it can be styled? I'm developing an app in CI, and I'd like a quick easy way to do this automatically.

jQuery is an option too...



Solution :

You should really be using the CodeIgniter URI Class to do this instead of the $_SERVER['REQUEST_URI']

$this->uri->uri_string()


if ( $this->uri->uri_string() == '/contact' )

^^ that is the preferred way to do things due to some complexities that can happen with codeigniter's routing features


    CSS Howto..

    How can I make the CSS-hover animation to stay?

    How to use nify javascript to make round corner box? Im using but not working

    How to apply css styles in embed widget

    How to hide the 2nd and 4th table row using css or jquery?

    How to give a line break between buttons in css/html?

    How to style a parent element when the mouse is over a child element?

    DIV Background Image Doesn't Show in Firefox or Chrome (But only online). Online it works for IE?

    How to aligning icon on right side of the screen when the screen size is small

    How to enlarge HTML text while keeping its center anchored at a point?

    Scroll Bar not Fully show the value In Div

    How to make this css readable?

    How can I hide a style element in html

    how to do external scripting?

    How to change position using CSS

    Can someone help me to know how I can make my layout work in small screen using css , css3?

    How do I keep my text on one line in Firefox?

    How do you fade horizontal text into a vertical gradient?

    How can I disable shrinking/resiziing images in Twitter Bootstrap?

    how to middle vertical-align using bootstrap input-group

    How to fit a dynamic PHP form in a div (to be able to fit fullpage.js)?

    How do I get this list to be seperated by a tab? (HTML/CSS)

    How to hide the “body” statement in css and javascript

    HTML/CSS/jQuery: How to set an “absolute text bottom” so that further text expands upwards?

    CSS How to use margins with different divs

    How to change/add CSS inside of iframe by jQuery

    How to add decoration to link in CSS?

    how do i css position this divs according to my layout picture?

    advice about how to vertically center content in fluid element

    How to create generic CSS class with input parameter

    How to prevent artifacts from appearing in Webkit when scrolling the page after stopping CSS animations