Index: custom_breadcrumbs_identifiers/custom_breadcrumbs_identifiers.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/custom_breadcrumbs/custom_breadcrumbs_identifiers/Attic/custom_breadcrumbs_identifiers.module,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 custom_breadcrumbs_identifiers.module --- custom_breadcrumbs_identifiers/custom_breadcrumbs_identifiers.module 3 May 2010 22:49:15 -0000 1.1.2.2 +++ custom_breadcrumbs_identifiers/custom_breadcrumbs_identifiers.module 10 May 2010 21:34:06 -0000 @@ -23,6 +23,7 @@ function custom_breadcrumbs_identifiers_ // Additional identifiers can be added here. $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('By prepending this identifier, the parent items for the given path are used as breadcrumb items (it can be 0 to n items).
  • The title information for this line would be ignored, because it will fetch the menu link titles.
  • A path has to get appended separated by a pipe (|) symbol, e.g. |node/[nid]
'); return $identifiers; } @@ -111,6 +112,57 @@ function custom_breadcrumbs_identifiers_ } } break; + + // Support for showing a paths parent menu link items as crumbs. + case '': + $title = $obj['title']; + $path = $obj['path']; + $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) { + // Parent ids of menu item + $pids = array( + $menu_item->plid, + $menu_item->p1, $menu_item->p2, $menu_item->p3, + $menu_item->p4, $menu_item->p5, $menu_item->p6, + $menu_item->p7, $menu_item->p8, $menu_item->p9, + ); + $pids = array_unique(array_filter($pids)); + + // Remove mlid + $mlid_key = array_search($menu_item->mlid, $pids); + if ($mlid_key !== FALSE) unset($pids[$mlid_key]); + + // return empty for no parents given. + if (!count($pids)) return array(); + + // Build replacement string + $s = implode(', ', array_fill(0, count($pids), "'%s'")); + // Query parent items. + $query = 'SELECT * FROM {menu_links} WHERE mlid IN ('. $s .')'; + $result = db_query($query, $pids); + $trail = array(); + + while ($item = db_fetch_object($result)) { + $i = array_search($item->mlid, $pids); + $trail[$i] = array( + 'title' => $item->link_title, + 'href' => $item->link_path, + 'crumb' => l($item->link_title, $item->link_path, $attributes), + ); + } + return $trail; + } + // empty for no menu entry given. + else { + return array(); + } + break; } return $crumb_items; }