Let’s say I have a controller function with these lines:
$this->load->view('stdHeader_view');
echo "<div class='main'>";
$this->loadView('foo_view');
echo '</div>';
$this->load->view('stdFooter_view');
This won’t do what I want, because $this->load->view() doesn’t immediately echo the view it loads, so the 2 echoed lines will appear at the top of the file that ultimately gets generated:
<div class='main'></div><html>...
So is there a way to do what I want, essentially “echo” snippets of HTML inline within the controller and have them appear in the same place relative to the views loaded above and below them? Obviously I could accomplish this by making entire view files for <div class='main'> and </div>, but this seems a little silly.
Why would you wan’t to do that?
You should load your variable data into the view and manipulate the view from the data instead.
If this really has to be done, do something like this: