theme_breadcrumb

5 theme.inc theme_breadcrumb($breadcrumb)
6 theme.inc theme_breadcrumb($breadcrumb)
7 theme.inc theme_breadcrumb($variables)
8 theme.inc theme_breadcrumb($variables)

Return a themed breadcrumb trail.

Parameters

$breadcrumb: An array containing the breadcrumb links.

Return value

a string containing the breadcrumb output.

Related topics

1 theme call to theme_breadcrumb()

File

includes/theme.inc, line 1301
The theme system, which controls the output of Drupal.

Code

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

Comments

_

I had to replace the separator (angle quotation mark) with it's html-entity to make it work. So &raquo; becomes » .

UTF-8 encoding…

If » does not work on your site without having to use HTML entities, it would seem that your site has encoding issues. Drupal sites should always use UTF-8…

Create Breadcrumbs from URL

I have found this post that uses this function to create breadcrumbs based off the URL.
Don't know who to give credit to, but thanks!

http://drupal.org/node/698666

How to make breadcrumb separator images

Here is a little snippet to make separator images

php

function phptemplate_breadcrumb($breadcrumb) {
   if (!empty($breadcrumb)) {
   $separator_icon = '<div class="breadcrumb-separator">&nbsp;&nbsp;&nbsp;&nbsp;</div>';
   $breadcrumb_string = '<div class="breadcrumb">'
   . implode($separator_icon, $breadcrumb)
   . '</div>';
   return $breadcrumb_string;
   }
}

css

div.breadcrumb-separator {
display: inline;
background: url(breadcrumb-separator.png) no-repeat bottom left;
}

simplify

If you base your theme function off the sample function theme_breadcrumb($breadcrumb) above in a fresh theme you end up with nested divs, with a class and ID of the same name.
You get this:

<div id="breadcrumb">
<div class="breadcrumb">
<a href="/">Home</a> » <a href="/link">Link 2</a>
</div>
</div>

Instead use:

function themename_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    return implode(' » ', $breadcrumb);
  }
}

And avoid the 2nd div.

Login or register to post comments