News Feed
Sections




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

Custom Scripts Blog:
Dynamic layouts in Twig
December 18, 2013 @ 12:18:14

On the Custom Scripts blog they've shared a new tutorial showing you how to use the popular PHP templating tool Twig to create dyanmic layouts for your application.

Recently I worked on a project that needed dynamic layouts for each bundle. The idea was to have a base template, then several layout templates that each extends from the base. Each view would then extend from one of the layout files.

In the scenario I had, I needed to allow each bundle to specify there own stylesheets and javascripts. So each bundle needed to create a custom layout that overrides the parent stylesheet and javascript block adding their own content, and I did not want to re-create the layout files for each bundle.

He's created a base template for the entire site leaving areas for stylesheet and javascript injection as well as making it flexible enough to accept multiple column layouts. Layered on top of this is a base template for each bundle that's then extended via a custom extension class as needed. The PHP is also included to define this and the other extension classes you'll need to make the setup work.

0 comments voice your opinion now!
twig template dyanmic tutorial

Link: http://blog.customscripts.co.za/dynamic-layouts-twig/

blog comments powered by Disqus

Similar Posts

Giorgio Sironi's Blog: Never write the same code twice: Dependency Injection

DeveloperTutorials.com: WordPress Customization

Matthew Weir O'Phinney's Blog: Cgiapp2 Tutorial 1 - Switch Template Plugins at Will

PHPMaster.com: Explore Aspect Oriented Programming with CodeIgniter, Part 2

Godaddyhostingreview Blog: How to move Magento from Production to Live Server


Community Events





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


developer code library application interview wordpress podcast framework series project threedevsandamaybe laravel release introduction language community api bugfix configure list

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