Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Issue links:
Description:
You can now really easily add new assets in template preprocess functions.
Drupal 7
function template_preprocess_maintenance_page(&$variables) {
drupal_add_library('core', 'normalize');
drupal_add_library('system', 'maintenance');
}
Drupal 8 <= beta1
function template_preprocess_maintenance_page(&$variables) {
// @see system_page_build()
$attached = array(
'#attached' => array(
'library' => array(
'core/normalize',
'system/maintenance',
),
),
);
drupal_render($attached);
}
Drupal 8 >=beta2
function template_preprocess_maintenance_page(&$variables) {
$variables['#attached']['library'][] = 'core/normalize';
$variables['#attached']['library'][] = 'system/maintenance';
}
Impacts:
Module developers
Themers