Nested views, need a solution |
[eluser]Unknown[/eluser]
I'm fairly new to CodeIgniter, and I've never really worked with frameworks, so bear with me. I'm setting up a blog (go figure), and I'm using some nested views, but unfortunately, the views are not being drawn as I had hoped. Here is my main view file... Code: <? $this->load->view('static/header.php') ?> And here is what $auth and $page are defined as in my home class. Code: function index() I would have thought that the page would end up being drawn in the order of Header, Auth, Page, and then Footer. However, it is drawn in the following order: Auth, Page, Header, Footer. I'm assuming this is on purpose so that headers aren't sent before the views are executed, so I'm looking for a solution to this problem without having to define some sort of $header and $footer template variable in every class file. Any help is appreciated.
[eluser]devbro[/eluser]
no no no. you forgot to pass the variables to your view. http://ellislab.com/codeigniter/user-gui...views.html and look up: Adding Dynamic Data to the View it explains how to send variables to view files. also keep in mind that loading a view does not stop the code from continuing. you either need to call die() or redirect().
[eluser]David Johansson[/eluser]
The variables are passed to the view by the load->vars() function, so that isn't the problem. The problem is that you are outputting your the auth and the page view when you are creating them instrad of returning them as strings. This should do it: Code: function index() When you add the third parameter TRUE to the view function the output is passed as a string. |
Welcome Guest, Not a member yet? Register Sign In |