title: Redirect to show_404 in Codeigniter from a partial view
body: <p>I am using the HMVC pattern in CodeIgniter. I have a controller that loads 2 modules via modules::run() function and a parameter is passed to each module. </p>
  
  <p>If either module cannot match the passed paramter I want to call show_404(). It works, but it loads the full HTML of the error page within my existing template so the HTML breaks and looks terrible. I think I want it to redirect to the error page so it doesn't run the 2nd module. Is there some way to do that and not change the URL?</p>
  
  <p>Is it possible to just redirect to show_404() from the module without changing the URL?</p>
  
  <p>Here is an over simplified example of what's going on:</p>
  
  <p><i>www.example.com/users/profile/usernamehere </i></p>
  
  <p>The url calls this function in the users controller:</p>
  
  <pre><code>function profile($username)
  {
      echo modules::run('user/details', $username);
      echo modules::run('user/friends', $username);
  }
  </code></pre>
  
  <p>Which run these modules, which find out if user exists or not:</p>
  
  <pre><code>function details($username)
  {
      $details = lookup_user($username);
      if($details == 'User Not Found')
          show_404(); // This seems to display within the template when what I want is for it to redirect
      else
          $this-&gt;load-&gt;view('details', $details);
  }
  
  function friends($username)
  {
      $details = lookup_user($username);
      if($friends == 'User Not Found')
          show_404(); // Redundant, I know, just added for this example
      else
          $this-&gt;load-&gt;view('friends', $friends);
  }
  </code></pre>
  
  <p>I imagine there is just a better way to go at it, but I am not seeing it. Any ideas?</p>