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']


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 to use CSS Loader in my website?

    CSS simple menu - how to align?

    how to set menu to activate always hover effect on [closed]

    How do I remove white space due to position relative of CSS?

    How to center align ion icon inside button?

    How can I avoid using too many classes in CSS?

    How to know if an element is rendered?

    How can I have a transparent overlay and center with flex box?

    How can I apply my CSS stylesheet to an RSS feed

    How to center my images in my case?

    How to set image in horizontal center of DIV to fill page width?

    How to center a Dijit Select widget?

    Multiple Read more issue in css, how do i solve that?

    How to do CSS wild card search? [duplicate]

    Facebook Like Button - how to disable Comment pop up box?

    My slideshow only cycles through one picture

    How can i repeat the image rollover and have multiple aligned underneath on my website?

    diagonal lines as background for css - how to switch angle

    Page not displaying, error not shown in console?

    How to best make a hover navbar?

    how to create the scrolling Menu in css?

    How to apply different styles based on the number oif col in a table

    Why won't my background show within div container?

    How to maintain an icon font from SVG files

    How to control the HTML area to the right?

    How to add the css properties to an image in ImageResourceCell of CellTable

    How to force font-weight on all children, but respect the nested depth

    How to get a gradient background for table rows with JSF and CSS?

    How to show/hide div on click with stricly HTML/CSS

    How to create a Vertical Strikethrough in CSS?