title: CodeIgniter: Way to use variable across entire site?
body: <p>I have a variable that has the first URL segment. I want to use this as a class on the <code>body</code> tag. It will mainly be used for setting links in my navigation as being active. Is there a way that I can create this variable in one place and use it in all of my controllers? Its not that big of a problem to set it in all of my controllers but I'd like to keep my code as clean as possible. This is what I have in my controllers right now:</p>
  
  <pre><code>$url_segment = $this-&gt;uri-&gt;rsegment_array(); //get array of url segment strings
  $data['url_segment'] = $url_segment[1]; //gets string of first url segment
  </code></pre>
  
  <p>Is there a way to only have the code above ONCE in my app, instead of inside all of my controllers? If so where should I place it?</p>