So I’ve been using CodeIgniter for a while now (love it), and I know I’m still learning the Model-Controller-View setup, but bare with me.
Ok, so I’m working on control panel style page, with a menu on top that allows navigation to various areas, and then a content area below to show those areas. The goal is to make it AJAX enabled.
The Admin() constructor checks if the user is authenticated and has the right permissions, otherwise it kills the routine and outputs an error.
The function ( show_users() ) just loads up the data (right now direct DB queries, eventually through a model), and parses it into a view file. This puts it into the output buffer (I believe).
Now comes the fun part. First I check to see if there’s a POST var called “ajax”, and if it’s set to true. If it is, then it pipes the buffer into a JSON object to be transferred out.
If not, then it stores the buffer into a var “content”, clears it, then parses out the templates (header, body (filling in this with the content variable), footer), and setting that as the output.
Then I echo out the output.
That’s all great, and works well. The trick is, I’m trying to implement a hook. I’m using Display_override to load up the buffer, preg_replace white space and such with blanks, and then displays that.
On all controllers that I don’t use the _output() function, Display_override will perform perfectly. On controllers that DO use _output(), the white space is still there.
There’s something very obvious right there… _output() takes over the Display_override.
So my first instinct is to look for an alternative for _output(). Something that runs after all the other functions, but before Display_override. Any thoughts?
Obviously, this isn’t mission critical. It just means that my controller for this section of the site isn’t as efficient in file transfer.. I’m just curious what the better method would be. Also looking for peer review of my setup for this system.