PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Joris de Wit's Blog: Extending different layouts for Ajax requests in Twig, Symfony2

Note: This article was originally published at PHPDeveloper on 30 August 2011.
PHPDeveloper

Joris de Wit has a (very) quick post about a handy tip he found about switching layouts easily with Twig in his Symfony2-based application - a handy ternary sort of switch that can detect when something's an Ajax request.

I just learned about the 'app' global variable in twig. It's very handy for loading a special layout for ajax requests.

The "app" variable allows you get get back at some of the settings of your application and check on special things like the isXMLHttpRequest in his example. For more information about Twig and how you can add it to your application, check out Twig-Project.org. Using it's as simple as adding a phar.