Drupal 8 Theme System: hook_theme() to Twig template


Slides: http://drupaltwig.github.io/ThemeSystemLA2015

Note: This talk is on the Symfony track because Twig is a technology that Symfony and Drupal 8 both leverage. We won't be talking about Symfony much (if at all) in this session.

The Twig templating engine is new for Drupal 8 and has generated a lot of excitement. Many passionate contributors have stepped up during the Drupal 8 development cycle to not only convert Drupal’s markup to Twig but also clean up and simplify the theme system as a whole. But what does all this mean to you?

This session covers the state of Drupal 8’s theme system. We'll talk about what’s different from Drupal 7 but also walk through some of the internals of different aspects of the theme system and how they might affect your day-to-day work with Drupal. Many parts of the session are applicable to Drupal 7’s theme system as well, so you can use some of the knowledge right away.

We’re going to talk a lot about code and APIs and look at plenty of PHP, so an understanding of PHP basics will be helpful.

Topics include:
  • A high-level summary of the changes to the theme system in Drupal 8.
  • An overview of the theme system as a whole and how things work in Drupal 7 vs. Drupal 8.
  • Some of the goodies that are possible now that we’re using Twig as our templating engine.
  • How to use theme hook suggestions to cut down on custom code and have themers thanking you.
  • Phases of the theme system and where you can step in to alter things.
  • Debugging tips, and Twig magic!

Session Track


Experience Level


Drupal Version

When & Where

Tuesday, 12 May, 2015 - 17:00 to 18:00
411 - Symfony