Welcome Guest, Not a member yet? Register   Sign In
CI 1.7 output buffer broken (for Controller->_output)
#11

[eluser]beemr[/eluser]
I think that their intention is to keep all echoes within the view file, and so support the MVC principle of separation.

My only gripe with the view loader is that it is strictly linear. If you want to be able to wrap a div around different combos of modules, then you are forced to clutter your view folder with a bunch of 12-character files. That's why I wrote a render library. It lets me set up a wrap of tags, an opening of tags, or a closing of tags around a view file.
#12

[eluser]mycroes[/eluser]
I think that they just haven't thought about it. Not too long ago it wasn't possible to load multiple views anyway, so everyone had to echo. That meant they couldn't cache the page if someone was using more than one view. I don't really care about small view files, I actually have a success, warning and error view which all contain just <div class="success|warning|error">$message</div> so I can easily show consistent errors and warnings. I do however care about having to do useless stuff, like loading a header and title in about every function, wehn solving that I ran into the issue this bug is about.
Regards,

Michael
#13

[eluser]Colin Williams[/eluser]
Quote:I do however care about having to do useless stuff, like loading a header and title in about every function, wehn solving that I ran into the issue this bug is about.

The Views system in CodeIgniter is THE way to present output to the client; THE way. So, when you decide to step out of this foundational convention, you are going to end up circumventing a lot of other things in CI. I have this feeling that you come up on these problems of logic and become frustrated that CI cannot solve your problem. The best experience with a framework can only be had if either your buy 100% in to its conventions, or you become familiar enough to know how to least destructively subvert the conventions, when it serves well to do so.

There are many ways to get global actions to happen on each request (like filling out a portion of the page that has nothing to do with the active controller--sidebars, headers, footers, etc.) Scour the forums and Wiki for specifics.
#14

[eluser]Colin Williams[/eluser]
Quote:I think that they just haven’t thought about it.

EllisLab is set to release the much anticipated version 2.0 of its immensely popular ExpressionEngine CMS, and it's built 100% on CI (perhaps even on this latest version, 1.7).

I think they've thought about it.
#15

[eluser]mycroes[/eluser]
[quote author="Colin Williams" date="1225456648"]
Quote:I do however care about having to do useless stuff, like loading a header and title in about every function, wehn solving that I ran into the issue this bug is about.

The Views system in CodeIgniter is THE way to present output to the client; THE way. So, when you decide to step out of this foundational convention, you are going to end up circumventing a lot of other things in CI. I have this feeling that you come up on these problems of logic and become frustrated that CI cannot solve your problem. The best experience with a framework can only be had if either your buy 100% in to its conventions, or you become familiar enough to know how to least destructively subvert the conventions, when it serves well to do so.[/quote]

I don't see the relation between my quoted post and your post... I'm using views, I'm actually even using a view for my template... Before multiple view support was introduced (I believe that was somewhere in the 1.6 series) the only possibility was to have multiple views loaded and concatenated with echo commands (echo $this->load->view('1', '', true); echo $this->load->view('2', '', true)Wink.

The fact that the codeigniter folks build other engines on top of CI doesn't mean they've thought about every possible combination of code execution. It still seems to me CodeIgniter is filling in the developer requirements, not necessarily the user requirements. That's not an issue, but that would explain if they haven't ever thought about buffering output that's being echoed... Maybe the codeigniter/expressionengine devs have nested views, with a parent view for every function inside controllers. That would work perfectly fine (because you can echo in a view as much as you want), and would allow them to cache the end result.

If I wanted to I could solve my issue the exact same way, but I don't want to... Because some people say the behaviour I'm describing in my bug report is expected behaviour, I'm just trying to figure out if that's true (truly expected) or that the devs just have never bothered to 'really' buffer all content because noone ever needed it.

In reaction to the last part of your quoted post above: I'm not frustated with this codeigniter behaviour, I'm just wondering about the correctness of the behaviour. I have actually already solved the behaviour for my issues, by loading views directly instead of echoing.

These days I always use views when creating new code, at least when working towards an end result, and I would suggest the same thing to anyone developing new code. I can however understand anyone using echoes (or print_r for that matter) in the process of developing new code. I can even understand people echoeing stuff for final use, although that probably means they're not efficiently using the MVC model. Do note however, that before multiple view support was available, echoing views was the only way to use multiple views from one controller function, and I think everyone will agree that to minimize code duplication you should sometimes split views into smaller parts.
Regards,

Michael
#16

[eluser]Colin Williams[/eluser]
Quote:Do note however, that before multiple view support was available, echoing views was the only way to use multiple views from one controller function

That's just wrong.

Code:
$data = array(
   'header' => $this->load->view('common/header', array(), TRUE),
   'content' => $this->load->view('common/content', array(), TRUE),
   'footer' => $this->load->view('common/footer', array(), TRUE),
);
$this->load->view('layout', $data);
// This is the premise behind my Template library

And look, I get what you're doing--you're using this scenario to play Gotcha! with the CI dev team--I just don't understand what ends you are trying to meet. EL is very clear about the direction they went with Views and output in CodeIgniter (as the docs show). Printing/echoing from a Controller is opposite that direction.

Quote:I’m just wondering about the correctness of the behaviour. I have actually already solved the behaviour for my issues

Well, no need to wonder anymore. It is the expected behaviour. The dev went the direction they did on purpose, not by accident or ignorance.
#17

[eluser]mycroes[/eluser]
[quote author="Colin Williams" date="1225494434"]
Quote:Do note however, that before multiple view support was available, echoing views was the only way to use multiple views from one controller function

That's just wrong.

Code:
$data = array(
   'header' => $this->load->view('common/header', array(), TRUE),
   'content' => $this->load->view('common/content', array(), TRUE),
   'footer' => $this->load->view('common/footer', array(), TRUE),
);
$this->load->view('layout', $data);
// This is the premise behind my Template library
[/quote]
True, I mentioned that in one of my posts too (that maybe CI devs are usign that for expressionengine in one or another way).

[quote author="Colin Williams" date="1225494434"]And look, I get what you're doing--you're using this scenario to play Gotcha! with the CI dev team--[/quote]
No, I filed a bug report because I thought it was broken. I would still expect the behaviour I explained from such a function (thus having buffered all content). As soon as you pointed out that it was expected behaviour my question became if this is really meant this way or has become this way but can still be changed in what I think is expectable.

[quote author="Colin Williams" date="1225494434"]EL is very clear about the direction they went with Views and output in CodeIgniter (as the docs show). Printing/echoing from a Controller is opposite that direction.[/quote]
It's a dirty job, but someone has to do it! Errr... Yes it's wrong, however all examples I've seen about loading multiple views before it was support featured echo-ing the content (and some of those were from respectable members in the community iirc). I also don't think the wrapping view you showed is a fix for the whole issue, it's a workaround (that's in security-terms, hope you're familiar with them and understand the meaning in this context). I do acknowledge that it's not an issue if you load multiple views these days and never echo anything, but I do not get why CI doesn't just start an output buffer when it loads and feeds that to the _output function...

[quote author="Colin Williams" date="1225494434"]
Quote:I’m just wondering about the correctness of the behaviour. I have actually already solved the behaviour for my issues

Well, no need to wonder anymore. It is the expected behaviour. The dev went the direction they did on purpose, not by accident or ignorance.[/quote]
Please let the devs talk for themselves. There's more ways to leave this out than just by accident or ignorance, for instance the fact that they never needed it... (Who knows, they might be using your template stuff in expressionengine Wink)
#18

[eluser]Colin Williams[/eluser]
Quote:but I do not get why CI doesn’t just start an output buffer when it loads and feeds that to the _output function

I don't know why either. I've been assuming it's because they see views as the only protocol for output (in conjunction with the Output class, of course). But, yeah, only assuming.

Quote:Please let the devs talk for themselves. There’s more ways to leave this out than just by accident or ignorance, for instance the fact that they never needed it… (Who knows, they might be using your template stuff in expressionengine wink)

Well, I typically go this direction, because it's good incentive for the dev team to hop in and clarify Smile And, from what I know about the current EE, I doubt Template is on their radar.
#19

[eluser]mycroes[/eluser]
[quote author="Colin Williams" date="1225509203"]
Quote:... (Who knows, they might be using your template stuff in expressionengine wink)

... And, from what I know about the current EE, I doubt Template is on their radar.[/quote]

I doubt so too, but seriously I think they really needed multiple view support, I can't really understand how anyone could do without if needing something just as simple as caching... (Mind that you can echo just fine when not caring for cache and not having some generic way of wrapping that expects codeigniter to catch output for you).

Also, I'm quite new to CodeIgniter, I only started using it about a year ago or so and I'm not really following development or anything. I read the changelogs, I update, and occassionally I visit the forums, mostly to see what solutions others think off when running into issues that seem common.

I also just thought of another way of working around this issue... Define a _remap function, start the output buffer before calling the real controller function, stop and clear the buffer directly after, and use that. Okay, this is ridiculous in general, but for my specific need it would work this time Smile.
Regards,

Michael
#20

[eluser]mycroes[/eluser]
[quote author="mycroes" date="1225510799"]I also just thought of another way of working around this issue... Define a _remap function, start the output buffer before calling the real controller function, stop and clear the buffer directly after, and use that. Okay, this is ridiculous in general, but for my specific need it would work this time Smile.
Regards,

Michael[/quote]

Actually, it won't work, unless I echo views... however when I would just load views it would be possible to $this->load->view('header'); $this->$method(); $this->load->view('footer');. Then again, this wouldn't allow the header to use things done in the method, such as printing a variable set in the method. Sometimes I should think more before I code...
Regards,

Michael




Theme © iAndrew 2016 - Forum software by © MyBB