Last updated 23 August 2009. Created on 27 March 2008.
Edited by lisarex, bekasu, dagomar. Log in to edit this page.

If you for any reason would like to add attributes to your breadcrumb links, this is how i did it; instead of

print $breadcrumb;

i did

print str_replace('">', '" target="_top">', $breadcrumb);

I needed this because i created a template with frames for external links. The top of the frame uses the standard "header" region, the bottom uses an external link. This snippet makes sure that when i click on a breadcrumb link, it will open in the "_top". You could use this to add any odd attribute though. I welcome cleaner methods, this worked for me though. It took me a while to figure this out so i thought i'd share.

Perhaps a Better Way

more "clean" way is to override theme function in template.php, insted of making breadcrumb changes in page.tpl.php

example: (template.php)

function mytheme_breadcrumb($breadcrumb) {
  $sep = ' > ';
  if (count($breadcrumb) > 0) {
    return implode($breadcrumb, $sep) . $sep;
  else {
    return t("Home");

or other example: (template.php)

function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';

more info:

Looking for support? Visit the forums, or join #drupal-support in IRC.


anou’s picture

This is how you added attributes, but what if you want to delete some ? I'm wondering how could I get rid of the attribute title in the of the the breadcrumb ?



anou’s picture

I didn't find the drupal way, but did it the "PHP way"...
I was trying to remove the "title" attribute, but this solution can be used for any attribute.

In template.php I added in my function MYTHEME_breadcrumb() like this:

function MYTHEME_breadcrumb($variables) {
  $breadcrumb = $variables['breadcrumb'];
  //pattern to find all title="anything-inside-double-quote"
  $pattern = "#title=\"(.+)?\"#";

  foreach($breadcrumb as $k => $value){
        //replace with nothing so title won't print
   	$breadcrumb[$k] = preg_replace($pattern, '', $value);

    //...some other code...
    $output .= '';
    return $output;

Thanks to regex ;-)
It took me some time, but nothing too long for accessibility...