node_entity_view_display_alter

node_entity_view_display_alter(EntityViewDisplayInterface $display, $context)

Implements hook_entity_view_display_alter().

File

core/modules/node/node.module, line 159
The core module that allows content to be submitted to the site.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
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);
        }
      }
    }
  }
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.