echo statements rendering out of order with multiple views? CodeIgniter newbie |
[eluser]Unknown[/eluser]
Hi I'm new to codeigniter and I have been trying to to make a main controller and instantiate other controllers like a menu controller, and then display the views, but the output seems to go out of order. Mainly echo statements seem to come out first. Anyone know why echo statements are rendered first? In my main controller I have: Code: $this->load->view('header',$header); Here's the code for showMenu, where the echo statements are. Code: function showMenu(){ I thought I would get header view fun in the sun calendar menu view instead I get: fun in the sun calendar header view menu view the two echo statements output first even though they are called second. Any help is appreciated. Thanks so much.
[eluser]Thorpe Obazee[/eluser]
You should be loading libraries like: http://ellislab.com/codeigniter/user-gui...aries.html Anyway, use the views to output anything to the browser.
[eluser]Dam1an[/eluser]
The reason for this, is that an echo is sent directly to the browser, but when you load a view, it gets buffered until you read the end of that controller function, then all the views which have been buffered get written to the screen at once
[eluser]TheFuzzy0ne[/eluser]
Output should only be sent from a view, unless of course you're debugging.
[eluser]Unknown[/eluser]
Thanks all. Super fast response! Ya I woke up this morning and realized that I was calling the echo statements in my menu controller not the view, and thus it wasn't being handled as part of the view. (Good to know the view buffer stream is cleared at the end of the controller function). I passed the calendar generate() output as a string to the view and it works perfectly ![]() Thanks again.
[eluser]Thorpe Obazee[/eluser]
[quote author="JojoBelmonte" date="1241476178"]Thanks all. Super fast response![/quote] ![]() |
Welcome Guest, Not a member yet? Register Sign In |