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

Breadcrumb

  1. Drupal Core 11.1.x
  2. NodeHooks1.php

function NodeHooks1::entityViewDisplayAlter

Implements hook_entity_view_display_alter().

File

core/modules/node/src/Hook/NodeHooks1.php, line 143

Class

NodeHooks1
Hook implementations for node.

Namespace

Drupal\node\Hook

Code

public function entityViewDisplayAlter(EntityViewDisplayInterface $display, $context) : void {
    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);
                }
            }
        }
    }
}

API Navigation

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