Theming

Exercise: Preprocess Functions for Drupal 8, 9, and 10

Preprocess functions allow you to change existing variables, or add new variables, for a template file using PHP code. In this exercise, you'll:

  • Define a PHP function that implements a preprocess hook
  • Create a new variable named {{ today }} that contains the current date and gets passed to the page.html.twig template file.

We recommend that you try the exercise's steps first, and refer to the video if you need help.

Frontend Theming