You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you try and load more than one View (for whatever reason) in one function, you see that it simply just won't work. There are a bunch of ways to do this
This method combines the output of all your views sequentially, so for example, you might have a view that sets up your headers, then your content, then your footers.
Find your function (or functions) where you have more than one view call ($this->load->view('', '', '');), and replace them with:
Also, the first View call must have php $output = before it. Then the View calls after the first one, have to have ```php
$output .=
You can also, alternatively, pass the $output variable to the Output Class that CodeIgniter has (for caching or things like that), like so:
```php
$output = $this->load->view('your_view', 'your_data', true);
$output .= $this->load->view('your_other_view', 'your_other_data', true);
$output .= $this->load->view('your_last_view', 'your_last_data', true);
$this->output->set_output($output);
... your output parsing, caching, etc code here ...
Method 2 - Embedding views
This method embeds a view within another view.
You can have a view that formats a menu, one that displays the contents of an article, and one that contains the overall template.
How this works is the first two views return output, which is added to our $template array. This array is then passed to the final template, where all the rendering happens.
The benefit of this over method #1 above is that each view contains a more-or-less standalone and relevant chunk of HTML (ie, you don't need a seperate header and footer that have
and , respectively). This makes adding things like the wrapper
much easier, as there's only one file to edit, and thus minimizes the possibility of unmatched elements and other HTML errors. To make things even easier to read, you can put HTML comments in your views at the start and end, like . When debugging, these will make the resulting HTML very simple to read.