Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / menu_breadcrumb_alter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/menu_breadcrumb_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/menu_breadcrumb_alter.twig
new file mode 100644 (file)
index 0000000..bef85eb
--- /dev/null
@@ -0,0 +1,15 @@
+/**
+ * Implements hook_menu_breadcrumb_alter().
+ */
+function {{ machine_name }}_menu_breadcrumb_alter(&$active_trail, $item) {
+  // Always display a link to the current page by duplicating the last link in
+  // the active trail. This means that menu_get_active_breadcrumb() will remove
+  // the last link (for the current page), but since it is added once more here,
+  // it will appear.
+  if (!drupal_is_front_page()) {
+    $end = end($active_trail);
+    if ($item['href'] == $end['href']) {
+      $active_trail[] = $end;
+    }
+  }
+}