Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_display_alter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_display_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/field_display_alter.twig
new file mode 100644 (file)
index 0000000..df86471
--- /dev/null
@@ -0,0 +1,13 @@
+/**
+ * Implements hook_field_display_alter().
+ */
+function {{ machine_name }}_field_display_alter(&$display, $context) {
+  // Leave field labels out of the search index.
+  // Note: The check against $context['entity_type'] == 'node' could be avoided
+  // by using hook_field_display_node_alter() instead of
+  // hook_field_display_alter(), resulting in less function calls when
+  // rendering non-node entities.
+  if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
+    $display['label'] = 'hidden';
+  }
+}