diff --git a/sites/all/modules/custom_breadcrumbs/custom_breadcrumbs_identifiers/custom_breadcrumbs_identifiers.module b/sites/all/modules/custom_breadcrumbs/custom_breadcrumbs_identifiers/custom_breadcrumbs_identifiers.module index 743f8cd..bc8eaae 100644 --- a/sites/all/modules/custom_breadcrumbs/custom_breadcrumbs_identifiers/custom_breadcrumbs_identifiers.module +++ b/sites/all/modules/custom_breadcrumbs/custom_breadcrumbs_identifiers/custom_breadcrumbs_identifiers.module @@ -24,6 +24,8 @@ function custom_breadcrumbs_identifiers_cb_identifier_list() { $identifiers[''] = t('Provides crumbs for each parent node of a book page. Whatever is placed in the corresponding position of the title area will be ignored. It should not be used with the pipe (|) symbol.'); $identifiers[''] = t('Provides a plain text crumb using the page title. Whatever is placed in the corresponding position of the title area will be ignored. It should not be used with the pipe (|) symbol.'); $identifiers[''] = t('Produces crumbs for each parent item for the given path. The title information for this line will be ignored because the menu link titles are used. If a path is not provided following the pipe (|) symbol, the current path with be used.'); + $identifiers[''] = t('Produces a crumb for the given path. The title information for this line will be ignored because the menu link title is used. If a path is not provided following the pipe (|) symbol, the current path with be used.'); + $identifiers[''] = t('Produces a crumb for the given menu item ID. The title information for this line will be ignored because the menu link title is used. An actual ID must be provided following the pipe (|) symbol.'); return $identifiers; } @@ -50,7 +52,7 @@ function custom_breadcrumbs_identifiers_cb_identifier_values($identifier, $obj) // Optionally wrap plain text crumb in span tag with class identifiers. if (variable_get('custom_breadcrumbs_none_span', FALSE)) { $class = 'custom-breadcrumbs-none'; - $attributes = $obj['attributes']['attributes']; + $attributes = $obj['attributes']['attributes']; if (!empty($attributes['class'])) { $attributes['class'] .= ' ' . $class; } @@ -179,7 +181,54 @@ function custom_breadcrumbs_identifiers_cb_identifier_values($identifier, $obj) return array(); } break; + + // Support for showing a paths parent menu link items as crumbs. + case '': + $crumb_items = array(); + $title = $obj['title']; + $path = ($obj['path'] != '') ? $obj['path'] : $_GET['q']; + $attributes = $obj['attributes']; + + // Search for both alias and normal path. + $normal_path = drupal_get_normal_path($path); + + $query = "SELECT * FROM {menu_links} WHERE link_path IN ('%s', '%s')"; + $menu_item = db_fetch_object(db_query_range($query, $normal_path, $path, 0, 1)); + + if ($menu_item) { + $crumb_items[] = array( + 'title' => $menu_item->link_title, + 'href' => $menu_item->link_path, + 'crumb' => l($menu_item->link_title, $menu_item->link_path, $attributes), + ); + } + return $crumb_items; + break; + + // Support for showing a paths parent menu link items as crumbs. + case '': + $crumb_items = array(); + $path = $obj['path']; + // check it's an actual menu item id, and do not accept an empty ID + if (!empty($path) && is_numeric($path)) { + $title = $obj['title']; + $attributes = $obj['attributes']; + + $query = "SELECT * FROM {menu_links} WHERE mlid = %d"; + $menu_item = db_fetch_object(db_query_range($query, $path, 0, 1)); + + if ($menu_item) { + $crumb_items[] = array( + 'title' => $menu_item->link_title, + 'href' => $menu_item->link_path, + 'crumb' => l($menu_item->link_title, $menu_item->link_path, $attributes), + ); + } + } + return $crumb_items; + break; } + return $crumb_items; }