function ClaroHooks::pageAttachmentsAlter
Same name and namespace in other branches
- main core/themes/claro/src/Hook/ClaroHooks.php \Drupal\claro\Hook\ClaroHooks::pageAttachmentsAlter()
Implements hook_page_attachments_alter().
Attributes
#[Hook('page_attachments_alter')]
File
-
core/
themes/ claro/ src/ Hook/ ClaroHooks.php, line 47
Class
- ClaroHooks
- Hook implementations for claro.
Namespace
Drupal\claro\HookCode
public function pageAttachmentsAlter(array &$attachments) : void {
$theme_path = \Drupal::request()->getBasePath() . '/' . \Drupal::service('extension.list.theme')->getPath('claro');
$query_string = \Drupal::service('asset.query_string')->get();
// Attach non-JavaScript specific CSS via a noscript tag to prevent unwanted
// layout shifts.
$attachments['#attached']['html_head'][] = [
[
'#tag' => 'link',
'#noscript' => TRUE,
'#attributes' => [
'rel' => 'stylesheet',
'href' => $theme_path . '/css/components/dropbutton-noscript.css?' . $query_string,
],
],
'dropbutton_noscript',
];
$attachments['#attached']['html_head'][] = [
[
'#tag' => 'link',
'#noscript' => TRUE,
'#attributes' => [
'rel' => 'stylesheet',
'href' => $theme_path . '/css/components/views-ui-noscript.css?' . $query_string,
],
],
'views_ui_noscript',
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.