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 17 May 2010 12:17:58 -0000 @@ -15,7 +15,7 @@ function custom_breadcrumbs_identifiers_cb_identifier_list() { $identifiers = array(); - $identifiers[''] = t('This will result in a plain text crumb. This identifier should not be used with the pipe (|) symbol.'); + $identifiers[''] = t('Produces a plain text crumb. This identifier should not be used with the pipe (|) symbol.'); if (module_exists('pathauto')) { $identifiers[''] = t('Cleans the given path using your pathauto replacement rules.'); } @@ -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('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 will be used.'); 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'] != '') ? $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) { + // 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 if no parents given. + if (!count($pids)) return array(); + + // Build the 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; + } + // Return an empty array if no menu entry is given. + else { + return array(); + } + break; } return $crumb_items; }