Drupal 8: Get machine name of a node in template_preprocess_node()

Profile picture for user Phil Frilling
By Phil Frilling, 26 August, 2016

/**
 * Implements template_preprocess_node().
 */
function THEME_preprocess_node(&$variables) {
  // Return the machine name of the node.
  $variables['node']->bundle();
}

Tags