function SearchNodeHooks::entityViewDisplayAlter
Implements hook_entity_view_display_alter().
Attributes
#[Hook('entity_view_display_alter')]
File
-
core/
modules/ search/ modules/ search_node/ src/ Hook/ SearchNodeHooks.php, line 55
Class
- SearchNodeHooks
- Hooks for the Search Node module.
Namespace
Drupal\search_node\HookCode
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);
}
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.