function NodeThemeHooks::preprocessHtml

Implements hook_preprocess_HOOK() for HTML document templates.

Attributes

#[Hook('preprocess_html')]

File

core/modules/node/src/Hook/NodeThemeHooks.php, line 235

Class

NodeThemeHooks
Hook implementations for the node module.

Namespace

Drupal\node\Hook

Code

public function preprocessHtml(&$variables) : void {
  // If on an individual node page or node preview page, add the node type to
  // the body classes.
  if (($node = $this->routeMatch
    ->getParameter('node')) || $node = $this->routeMatch
    ->getParameter('node_preview')) {
    if ($node instanceof NodeInterface) {
      $variables['node_type'] = $node->getType();
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.