function node_theme_suggestions_node

Same name in other branches
  1. 9 core/modules/node/node.module \node_theme_suggestions_node()
  2. 10 core/modules/node/node.module \node_theme_suggestions_node()
  3. 11.x core/modules/node/node.module \node_theme_suggestions_node()

Implements hook_theme_suggestions_HOOK().

File

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

Code

function node_theme_suggestions_node(array $variables) {
    $suggestions = [];
    $node = $variables['elements']['#node'];
    $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
    $suggestions[] = 'node__' . $sanitized_view_mode;
    $suggestions[] = 'node__' . $node->bundle();
    $suggestions[] = 'node__' . $node->bundle() . '__' . $sanitized_view_mode;
    $suggestions[] = 'node__' . $node->id();
    $suggestions[] = 'node__' . $node->id() . '__' . $sanitized_view_mode;
    return $suggestions;
}

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