Organizational Research By

Surprising Reserch Topic

how to get Current URI Segment in CodeIgniter


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

$data['current_uri'] = $this->uri->segment(1);
$this->load->view('header', $data);

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.


asked Jun 10, 2015 in codeinither by rajesh
0 votes
39 views



Related Hot Questions

1 Answer

0 votes
NULL
answered Jun 10, 2015 by rajesh

...