Last active
November 9, 2015 12:53
-
-
Save SebCorbin/37c795b016de72dadfd5 to your computer and use it in GitHub Desktop.
Revisions
-
SebCorbin revised this gist
Nov 9, 2015 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -43,3 +43,14 @@ function fixtrail_page_delivery_callback_alter(&$callback) { $preferred_links[$current_path] = $preferred_links[$parent_path]; } } /** * Implements hook_menu_breadcrumb_alter(). */ function fixtrail_menu_breadcrumb_alter(&$active_trail, $item) { // Add the current page to the breadcrumb, if not already done. $end = end($active_trail); if (current_path() != $end['href']) { $active_trail[] = $item; } } -
SebCorbin created this gist
Nov 9, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ <?php /** * Implements hook_page_delivery_callback_alter(). */ function fixtrail_page_delivery_callback_alter(&$callback) { $current_path = current_path(); // Only work on normal pages, not ajax nor admin pages. if ($callback != 'drupal_deliver_html_page' || path_is_admin($current_path)) { return; } $parent_path = NULL; // Set the nearest parent given certain conditions. $item = menu_get_item(); if ($item['path'] == 'node/%') { $node = $item['map'][1]; if ($node->type == 'evenement') { $parent_path = 'evenements'; } elseif ($node->type == 'dossier') { $parent_path = 'dossiers'; } elseif ($node->type == 'produit') { $parent_path = 'produits'; } } elseif ($item['path'] == 'taxonomy/term/%') { $term = $item['map'][2]; if ($term->vocabulary_machine_name == 'lexique') { $parent_path = 'lexique'; } } // If parent found, set it for menu tree trail future build. if ($parent_path) { menu_tree_set_path('menu-header-main', $parent_path); menu_link_get_preferred($parent_path); // Fool drupal so that it take the correct link to build the breadcrumb. $preferred_links = &drupal_static('menu_link_get_preferred'); $preferred_links[$current_path] = $preferred_links[$parent_path]; } }