-1

I was wondering if it is possible to store the output created by silex. What I want to achieve is something like this :

<?php
    require('core.php');
    $out = $app->run();
    echo $app['twig']->render('header.html');
    echo $out;
    echo $app['twig']->render('footer.html');

I'd like to do it this way because some of the navigation is build inside my dynamic controllers and registered as a global into twig. I've tried to use the out buffering ob_start mechanism without succes :

<?php
    require('core.php');
    ob_start();
    $app->run();
    $out = ob_get_contents();
    ob_end_clean();
    echo $app['twig']->render('header.html');
    echo $out;
    echo $app['twig']->render('footer.html');

Any other ideas on this subject ?

1 Answer 1

1

Instead of having a split of header/main/footer and using the global variables, you should use an unique template with template inheritence.

http://twig.sensiolabs.org/doc/templates.html#template-inheritance

1
  • This is true. I should swap out my MiddleWare with this mechanic and move my menu build up to a custom Twig_SimpleFunction
    – DarkBee
    Sep 28, 2013 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.