function node_entity_view_display_alter

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

Implements hook_entity_view_display_alter().

File

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

Code

function node_entity_view_display_alter(EntityViewDisplayInterface $display, $context) {
    if ($context['entity_type'] == 'node') {
        // Hide field labels in search index.
        if ($context['view_mode'] == 'search_index') {
            foreach ($display->getComponents() as $name => $options) {
                if (isset($options['label'])) {
                    $options['label'] = 'hidden';
                    $display->setComponent($name, $options);
                }
            }
        }
    }
}

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