News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Joris de Wit's Blog:
Extending different layouts for Ajax requests in Twig, Symfony2
August 29, 2011 @ 11:39:34

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.

0 comments voice your opinion now!
twig symfony2 layout switch template ajax request


blog comments powered by Disqus

Similar Posts

Chris Hartjes' Blog: Better HTTP Request/Response in PHP

Shameer Chamal's Blog: Tutorial : Simple ajax validation for Kohana

The Bakery: Four New Articles - Load Balancing, Request Info, UUID Behavior & Upload Thumbnails

Zend Developer Zone: Creating Web Page Templates with PHP and Twig (part 1)

Kian Hui Teo\'s Blog: Switching between PHP 5.1.x and Zend Core for Oracle


Community Events

Don't see your event here?
Let us know!


example framework interview performance conference community api release laravel series symfony2 library introduction podcast php7 extension version install voicesoftheelephpant opinion

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework