I’m very new to CI, but it’s been working great so far. My only problem seems to stem from nested views; some are rendering out of order. Currently, I have a login form that is supposed to display in my “header,” but is instead rendering before the entire page. I’ve read some older topics in the forums regarding this (http://ellislab.com/forums/viewthread/88335/ and http://ellislab.com/forums/viewthread/113358/#573470), as well as some guides online, but I’m still not sure I understand best practice.
What I’m trying to do is create a view that is essentially a template for 90% of the pages on my site, simply so that I don’t have to load multiple views in the controllers each time (i.e. header, content, footer). template.php looks like this:
All controller functions will set the necessary variables and load this file using:
At this point, everything is displaying properly.
header.php looks like this:
[all html, head, body, etc...]
<?php if(modules::run('membership/_isLoggedIn', FALSE)) : ?>
<?php else : ?>
<?php $this->load->view('membership/login_form'); ?>
<?php endif; ?>
Finally, login_form.php is something like this:
This is obviously shortened, but essentially if the user is logged in, data is displayed. If not, a login form is displayed in the header.
The issue arises here. When the page is rendered, the login form is displayed at the very top, even above the <!DOCTYPE> and everything else in header.php. Why would this be rendering out of order? Should I not be using nested views like this? If not, what is the appropriate method?
If it changes anything, I’m running HMVC.
Thanks for your help!
Forgot to mention one other piece of information. If the use is logged in, the data is displayed correctly in the header. It is only out of order when loading the login_form view.