Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. node.module

function node_preprocess_html

Implements hook_preprocess_HOOK() for HTML document templates.

File

core/modules/node/node.module, line 231

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal