Current URI Segment in CodeIgniter

DavisGordon

New Member
What would be the best way to check for the current URI segment in a CodeIgniter view? What I am trying to do is use the current URI segment [i.e. $this->uri->segment(1)] in order to highlight the current page on the navigation bar.The best that I have figured out is to do\[code\]$data['current_uri'] = $this->uri->segment(1);$this->load->view('header', $data);\[/code\]in each of my controllers and then in the header.php file, I check the $current_uri variable to determine which part of the navigation should be highlighted. As you know, this is a very tedious way of doing it, but I'm at a loss of a better way to do this.It may even be possible to extend the default Controller class to pass the current URI segment, but I'm not sure if this would work, or even how to go about doing it.
 
Back
Top