--- C:/xampp/htdocs/drupal/sites/all/modules/menu_breadcrumb/menu_breadcrumb.module.original Fri Jul 01 07:19:23 2011 +++ C:/xampp/htdocs/drupal/sites/all/modules/menu_breadcrumb/menu_breadcrumb.module Thu Jul 12 16:12:37 2012 @@ -11,6 +11,21 @@ * As an added bonus, it also allows you to append the page title to the * breadcrumb (either as a clickable url or not) and hide the breadcrumb * if it only contains the link to the front page. + * + */ + +/* + * Modifications: + * ===================== + * Name: Paul Schnapp + * Date: 2012.07.12 + * E-mail: paul dot schnapp at gmail dot com + * Company: Micro Industries + * Modification Summary: + * Customized module to create a link for a menu in the breadcrumbs (just after "Home") when a URL is provided for that menu. + * Needs testing! + * Submitted a patch to menu_breadcrumb project on drupal.org. + * Added "Modifications" portion to header in compliance with GPL v2 license. (Feel free to take this out if/when integrating it into the original project, I don't need credit). */ define('MENU_BREADCRUMB_REGEX_DEFAULT', '/^book-toc-\d+$/Books/'); @@ -59,6 +74,8 @@ 'menu_breadcrumb_default_menu' => array( 'enabled' => 1, 'weight' => 0, + 'menu_link_url' => '', + 'menu_link_text' => '', 'type' => 'menu_breadcrumb_default_menu', ), ); @@ -156,17 +173,23 @@ // Use the known enabled/weight values for this pattern. $enabled = $menus[$pattern]['enabled']; $weight = $menus[$pattern]['weight']; + $menu_link_url = $menus[$pattern]['menu_link_url']; + $menu_link_text = $menus[$pattern]['menu_link_text']; } else { // A genuinely unknown menu. Use default values. $disable = in_array($menu_name, $disabled_by_default, TRUE); $enabled = $disable ? FALSE : $menus['menu_breadcrumb_default_menu']['enabled']; $weight = $disable ? count($menus) : $menus['menu_breadcrumb_default_menu']['weight']; + $menu_link_url = $disable ? '' : $menus['menu_breadcrumb_default_menu']['menu_link_url']; + $menu_link_text = $disable ? '' : $menus['menu_breadcrumb_default_menu']['menu_link_text']; } $new_menus[$menu_name] = array( 'enabled' => $enabled, 'weight' => $weight, + 'menu_link_url' => $menu_link_url, + 'menu_link_text' => $menu_link_text, 'type' => 'menu', ); } @@ -296,6 +319,8 @@ */ function menu_breadcrumb_init() { $is_front = drupal_is_front_page(); + $link_menu_index = ''; // array index of menu to use for a link, if enabled. + if (variable_get('menu_breadcrumb_determine_menu', 1) && !$is_front) { // Find the set of menus containing a link for the current page. $menu_item = menu_get_item(); @@ -317,6 +342,7 @@ if (array_key_exists($menu_link_menu_name, $match_cache) && $match_cache[$menu_link_menu_name] == $menu_name) { menu_set_active_menu_names($menu_link_menu_name); + $link_menu_index = $menu_name; break 2; } } @@ -326,6 +352,7 @@ $active_menus = menu_get_active_menu_names(); $active_menus[] = $menu_name; menu_set_active_menu_names($active_menus); + $link_menu_index = $menu_name; break; } } @@ -335,6 +362,16 @@ // Generate the breadcrumbs using the active menu. $breadcrumb = drupal_get_breadcrumb(); + // Add a link for the menu to the beginning (after Home) if a URL is set for it. + $menus = variable_get('menu_breadcrumb_menus', _menu_breadcrumb_default_menu()); + if (!$is_front + && $link_menu_index != '' + && $menus[$link_menu_index]['menu_link_url'] != '') { + $home = array_shift($breadcrumb); + array_unshift($breadcrumb, $home, l(t($menus[$link_menu_index]['menu_link_text']), + $menus[$link_menu_index]['menu_link_url'])); + } + if (variable_get('menu_breadcrumb_append_node_title', 0) == 1) { if (variable_get('menu_breadcrumb_append_node_url', 0) == 1) { $breadcrumb[] = $is_front ? l(t('Home'), '') : l(drupal_get_title(), $_GET['q'], array('html' => TRUE,)); @@ -389,7 +426,7 @@ $form['include_exclude'] = array( '#type' => 'fieldset', '#title' => t('Enable / Disable Menus'), - '#description' => t('The breadcrumb will be generated from the first "enabled" menu that contains a menu item for the page. Re-order the list to change the priority of each menu.'), + '#description' => t('The breadcrumb will be generated from the first "enabled" menu that contains a menu item for the page. Re-order the list to change the priority of each menu.
If you would like a link for a menu to be included in the breadcrumbs between the "Home" link and the rest of the breadcrumbs, enter link text and a URL into the "Menu Link Text" and "Menu Link URL" fields, respectively, for that menu; when a URL field is blank, a link will not be displayed for that menu -- use "<front>" to link to the home page.'), ); $form['include_exclude']['note_about_navigation'] = array( @@ -432,6 +469,16 @@ 'label' => array( '#value' => $menu_name, ), + 'menu_link_url' => array( + '#type' => 'textfield', + '#default_value' => $menu['menu_link_url'], + '#id' => $safe_id_prefix .'-menu_link_url', + ), + 'menu_link_text' => array( + '#type' => 'textfield', + '#default_value' => $menu['menu_link_text'], + '#id' => $safe_id_prefix .'-menu_link_text', + ), 'weight' => array( '#type' => 'weight', '#default_value' => !empty($menu['weight']) ? (int) $menu['weight'] : 0, @@ -561,6 +608,8 @@ $table['attributes']['id'] = 'menu-breadcrumb-menus' ; $table['header'] = array( t('Menu'), + t('Menu Link Text'), + t('Menu Link URL'), t('Enabled'), t('Weight'), ); @@ -572,6 +621,8 @@ $menu = &$form[$key]; $row = array(); $row[] = drupal_render($menu['title_display']); + $row[] = drupal_render($menu['menu_link_text']); + $row[] = drupal_render($menu['menu_link_url']); $row[] = drupal_render($menu['enabled']); $menu['weight']['#attributes']['class'] = array('menu-weight'); $row[] = drupal_render($menu['weight']);