Welcome Guest, Not a member yet? Register   Sign In
Require_once in all controller, but not in all...

Hi guys.

My problem today is:

I have to include this code:




at the very top and very bottom of all my pages to compress css and js files.
I think to put the two lines in index.php, but there's a problem when there is an ajax call.

And if your script is redirecting to another location (Ajax) then there’s nothing to compress, so don’t add the PHP Speedy code to that page.

So, I have to put the two lines of code in all my controllers, not in ones that returns an Ajax call... Some ideas to do that? I think is not the best way write the lines in all my controllers...

Thank you, sorry for english.

why not try something like this
add the following code to your controllers
function _output($output) {
    if (!$this->_ajax) {
        echo $output;
    } else {
        echo $output;
This will use your compression code if the _ajax property of the controller is false
So then you just need to declare the variable in the controller
class XXX extends Controller {

    var $_ajax = false;

    function xxx() {
and then if the method in the controller will be returning ajax set the property to true
$this->_ajax = true;
much neater and you do not have to put the code in multiple times

Theme © iAndrew 2016 - Forum software by © MyBB