How can I change the displayed root of my breadcrumb trail at a certain point?
Lets say my breadcrumbs map the solar system. I want my displayed trail to begin with Solar System until I get to USA, at which point I want USA to be the root. So I would have trails like this for other planets/continents/countries:
Solar System > Jupiter > Big Red Swirl
Solar System > Earth > Australia > Sydney
Solar System > Earth > North America > Canada
But once I get to USA, instead of the breadcrumb trail appearing as...
Solar System > Earth > North America > USA
...I would like USA to become the displayed root
USA
USA > Ohio
USA > California > San Fransisco
Anyone know how I can implement this, whether Drupal module, Drupal technique, or code in my template.php file?
Here is the code in the php template that creates the breadcrumbs:
function cph_main_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
$youAreHere = drupal_get_title();
$crumbs = ' ';
if (!empty($breadcrumb)) {
$crumbs = '<ul>';
foreach($breadcrumb as $value) {
$crumbs .= '<li>' .$value.'</li>';
}
$crumbs .= '<li>' . $youAreHere . '<li></ul>';
}
return $crumbs;
}
If the current breadcrumb value is the one for "USA" reset the breadcrumb and start it again.
If you want to find the current item for USA dpm() the $breadcrumb to find out. Notice that if the link to USA change later you have to change it here also...