Welcome Guest, Not a member yet? Register   Sign In
Nested Views Rendering Out of Order
#1

[eluser]nickp[/eluser]
Hi all,
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:
Code:
<?php
$this->load->view('includes/header');

$this->load->view($main_content);

$this->load->view('includes/footer');
?>


All controller functions will set the necessary variables and load this file using:
Code:
$this->load->view('template', $data);


At this point, everything is displaying properly.
header.php looks like this:
Code:
[all html, head, body, etc...]
<div id="utility">
&lt;?php if(modules::run('membership/_isLoggedIn', FALSE)) : ?&gt;
    ...
    various data
    ...
&lt;?php else : ?&gt;
    &lt;?php $this->load->view('membership/login_form'); ?&gt;
&lt;?php endif; ?&gt;
</div>


Finally, login_form.php is something like this:
Code:
<div id="login_form">
echo form_open('blah');
echo form_input(...)
...
echo form_close();
</div>


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!

edit:
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.


Messages In This Thread
Nested Views Rendering Out of Order - by El Forum - 04-06-2011, 05:25 PM
Nested Views Rendering Out of Order - by El Forum - 04-06-2011, 05:37 PM
Nested Views Rendering Out of Order - by El Forum - 04-06-2011, 09:40 PM
Nested Views Rendering Out of Order - by El Forum - 04-06-2011, 10:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB