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

后端 未结 5 2206
走了就别回头了
走了就别回头了 2021-02-09 15:02

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 automat

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-09 16:01

    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

提交回复
热议问题