title: CodeIgniter Initial Page Load Variable?
body: <p>I'm looking for a solution to loading the header/footer/navigation only on the initial page view.</p>
  
  <p>The reasoning behind this is that my navigation panel uses Ajax to render the content of the destination link in the main content div instead of actually loading the page itself.</p>
  
  <p>However, I need to be able to say something along the lines of if its the initial view, load the header, navigation, then the actual page, then the footer. But if its not the initial view and the page is loaded in the content div area so for example a navigation link or a form submit, it doesn't load the header, navigation and footer but only the actual page.</p>
  
  <p>So for example I have these 4 views:</p>
  
  <p>header_view
  navigation_view
  page_a_view
  footer_view</p>
  
  <p>And this controller:</p>
  
  <p>controller_a</p>
  
  <p>The navigation has a link which is 'Page A' and points to <a href="http://myurl.com/controller_a" rel="nofollow">http://myurl.com/controller_a</a>. If that link is clicked I only wanted controller_a to load the page_a_view view, because the navigation link will load the data of that page into the div.</p>
  
  <p>However if I directly go to <a href="http://myurl.com/controller_a" rel="nofollow">http://myurl.com/controller_a</a>, it needs to render the the header/navigation/footer also.</p>
  
  <p>The solution I thought I was on the right lines with was something like a base controller with a function load_page() which would be something like:</p>
  
  <pre><code>function load_page($page, $data) {
  
      if($this-&gt;uri-&gt;segment($this-&gt;uri-&gt;total_segments()) == "initial_page_load") {
          $this-&gt;load-&gt;view('header_view');
          $this-&gt;load-&gt;view('navigation_view');
          $this-&gt;load-&gt;view($page, $data);
          $this-&gt;load-&gt;view('footer_view');
      } else {
          $this-&gt;load-&gt;view($page, $data);
      }
  
  }
  </code></pre>
  
  <p>So if I was to go to <a href="http://myurl.com/controller_a/initial_page_load" rel="nofollow">http://myurl.com/controller_a/initial_page_load</a> it would load the header/navigation/footer but if I went to <a href="http://myurl.com/controller_a" rel="nofollow">http://myurl.com/controller_a</a> it wouldn't.</p>
  
  <p>However this doesn't cover all possibilities.</p>
  
  <p>Another way I thought of is checking if there is a referring URL, if there is, don't load the header/navigation/footer. But again, this doesn't cover things such as what if the link was referred by an external website?</p>
  
  <p>Does anyone have any suggestions to how I can achieve what I need?</p>