Last updated July 26, 2017
Theming8.3.x

Preprocess functions allow Drupal themes to manipulate the variables that are used in Twig template files by using PHP functions to preprocess data before it is exposed to each template. All of the dynamic content available to theme developers within a Twig template file is exposed through a preprocess function. Understanding how preprocess functions work, and the role they play, is important for both module developers and theme developers.

In this tutorial we'll learn about:

  • What preprocess functions are and how they work
  • The use case for preprocess functions
  • The order of execution for preprocess functions