Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / views_post_build.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/views_post_build.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/views_post_build.twig
new file mode 100644 (file)
index 0000000..bfd2572
--- /dev/null
@@ -0,0 +1,16 @@
+/**
+ * Implements hook_views_post_build().
+ */
+function {{ machine_name }}_views_post_build(ViewExecutable $view) {
+  // If the exposed field 'type' is set, hide the column containing the content
+  // type. (Note that this is a solution for a particular view, and makes
+  // assumptions about both exposed filter settings and the fields in the view.
+  // Also note that this alter could be done at any point before the view being
+  // rendered.)
+  if ($view->id() == 'my_view' && isset($view->exposed_raw_input['type']) && $view->exposed_raw_input['type'] != 'All') {
+    // 'Type' should be interpreted as content type.
+    if (isset($view->field['type'])) {
+      $view->field['type']->options['exclude'] = TRUE;
+    }
+  }
+}