Drupal 8 Theming Deep Dive
Drupal 8 Theming Deep Dive
Deep Dive
Romain JARRAUD
Trainer/consultant
Trained People
@romainjarraud (mainly in french)
What is theming?
Theming?
Fonctionnal Display
Request
Theme
HTML
Drupal &
Templates
modules Content
Create a theme
Create a theme
• /themes/ive/ive.info.yml
End of the story!
Maybe not…
Theme files
Templates
TWIG
$variables
$variables
Default
Template
preprocess
Called functions order
Theme suggestions
• MODULE_theme_suggestions_HOOK(array $variables)
• OTHERMODULE_theme_suggestions_alter(array &$suggestions, array $variables,
$hook)
• OTHERMODULE_theme_suggestions_HOOK_alter(array &$suggestions, array
$variables)
• THEME_theme_suggestions_alter(array &$suggestions, array $variables, $hook)
• THEME_theme_suggestions_HOOK_alter(array &$suggestions, array $variables)
Preprocess
• template_preprocess_HOOK(array &$variables)
• OTHERMODULE_preprocess(array &$variables, $hook)
• OTHERMODULE_preprocess_HOOK(array &$variables)
• THEME_preprocess(array &$variables, $hook)
• THEME_preprocess_HOOK(array &$variables)
Librairies
Librairies
• No more manually asset loading.
• Bye bye drupal_add_css(), drupal_add_js()
and drupal_add_library()!
• Must add any asset through a library.
• Drupal takes care of libraries loading and
dependencies.
Librairies
Declaration Loading
Libraries declaration
/themes/ive/ive.libraries.yml
Libraries loading
Loading from /themes/ive/ive.info.yml
Libraries loading
/themes/ive/js/ive.js
Breakpoints
Breakpoints
Defines:
• ive.settings configuration.
• « ive » with its default value « one ».
This configuration is loaded during installation.
Configuration
/themes/ive/ive.theme
Configuration
Theme hook
declaration
Theme hook declaration