![]() |
CI 1.7 output buffer broken (for Controller->_output) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CI 1.7 output buffer broken (for Controller->_output) (/showthread.php?tid=12758) |
CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]mycroes[/eluser] Somehow only views are buffered, content echo-ed is not buffered. Test code: Code: class Test extends Controller { Using $this->load->view() will work, as long as you don't use echo $this->load->view($param1, $param2, true); Of course everything can be done just by loading views, but I still have some dirty code that uses more than just views... Regards, Michael CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]Pascal Kriete[/eluser] CodeIgniter does not use the native PHP output buffer. All view contents are stored in a variable instead. This variable is passed to the _output function. You can easily add your own output to the CI buffer though: Code: ob_start(); Hope that helps. CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]mycroes[/eluser] Why isn't codeigniter using a native php output buffer, or any real output buffer? Seems to me that a function called _output with $output as parameter should receive all output... Also from this I would understand that caching wouldn't work when echoing, and if it does why isn't the same data that's written to cache passed as parameter to the _output function? I'd like some confirmation that current behaviour is as expected... Regards, Michael CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]Pascal Kriete[/eluser] I can't tell you why they do it this way, but I do know that I've used it to my advantage multiple times. Particularly for downloads and async requests. The caching documentation is pretty clear on this though: Quote:Warning: Because of the way CodeIgniter stores content for output, caching will only work if you are generating display for your controller with a view. CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]mycroes[/eluser] I'm currently converting all my pages to get rid of the echos, some pages however don't use views at all right now (written in a few hours, work, so left untouched after that). If anyone else runs into this problem, it's always possible to have a view that just echoes content and then repalce all your echoes with view-loading... Regards, Michael CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]beemr[/eluser] I wrote a quick function for bypassing the view but still getting into the output. Code: function bypass_view($rushtml) Just fill $rushtml with your entity-encoded html; CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]Pascal Kriete[/eluser] @Beemr, why are you buffering the output for one echo? Code: // PHP 4 requires that we use a global CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]beemr[/eluser] Honestly, I can't remember :roll: , but I think that I was considering the Template_Inheritance_Helper at the time, which made use of the output buffer to create Django-style templates. It was a neat helper, but I ultimately decided it was overkill versus the just-then-released multiple view loader. You are right, the ob is unnecessary here. CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]beemr[/eluser] Sure enough. The function should be: Code: function bypass_view($rushtml) Thanks for the optimization, Inparo CI 1.7 output buffer broken (for Controller->_output) - El Forum - 10-30-2008 [eluser]mycroes[/eluser] I could wrap that up into my layout controller, but I still think the CodeIgniter behaviour is wrong... And I'm still waiting for a CodeIgniter dev to answer if this is indeed expected behaviour and if it will always be this way (I for one can understand that people also want to have pages they 'echo' cached...). |