Currently, I've got this code in my (D6) template.php - to convert the $breadcrumb links into list items, so that I can style them:

function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    $lastitem = sizeof($breadcrumb);
    $crumbs = '<ul class="breadcrumbs">';
    $a=1;
    foreach($breadcrumb as $value) {
        if ($a!=$lastitem){
         $crumbs .= '<li>'.$value.'</li>';
         $a++;
        }
        else {
            $crumbs .= '<li class="breadcrumbcurrent">'.$value.'</li>';
        }
    }
    $crumbs .= '</ul>';
  }
  return $crumbs;
}

This code also allows me to style the last (current page) item of those links... My question is, how would I go about adding a class to the first item of the list as well? I'm not much for PHP/coding, so this is a little hard for me to wrap my head around.

I'd also like to display the current page's title in the breadcrumb as the current page (last list item)... as of right now it displays the page that you came from at the end of the trail, not the current page's title.

Comments

archi’s picture

Hi,

Change the class according to your needs.

function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    $lastitem = sizeof($breadcrumb);
    $crumbs = '<ul class="breadcrumbs">';
    $a=1;
    foreach($breadcrumb as $value) {
        if ($a!=$lastitem && $a != 1){
         $crumbs .= '<li>'.$value.'</li>';
         $a++;
        }
        elseif($a == 1) {
          $crumbs .= '<li class="breadcrumbfirst">' . $value . '</li>';
          $a++;
        }
        else {
            $crumbs .= '<li class="breadcrumbcurrent">' . $value . '</li>';
        }
    }
    $crumbs .= '</ul>';
  }
  return $crumbs;
}

mtcrutch’s picture

archi, thank you so much! worked like a charm.

i'm still trying to figure out how to get the most current page's title displayed at the end of the breadcrumb; in this screen, it should be "freshwater fishing": http://www.crutchdesigns.com/fts/fts-breadcrumb.jpg

thanks again for taking the time to look at the issue, archi. much appreciated.

arh1’s picture

it's always a good idea to poke around on the API site to see what precedents there are in core.

here's an example of what you're looking for: http://api.drupal.org/api/function/theme_links/6

mtcrutch’s picture

arh1, thanks for the link. i've poked around a little, but without knowing much php, it's hard to figure out exactly what to look for. i guess it's time i actually learned php!