Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / entity_view_mode_alter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/entity_view_mode_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/entity_view_mode_alter.twig
new file mode 100644 (file)
index 0000000..c9e2cb7
--- /dev/null
@@ -0,0 +1,9 @@
+/**
+ * Implements hook_entity_view_mode_alter().
+ */
+function {{ machine_name }}_entity_view_mode_alter(&$view_mode, $context) {
+  // For nodes, change the view mode when it is teaser.
+  if ($context['entity_type'] == 'node' && $view_mode == 'teaser') {
+    $view_mode = 'my_custom_view_mode';
+  }
+}