Google launches from not long time, a better semantic way to write breadcrumb in html.
It will help google(and other for sure) to better detect and understand content of breadcrumbs.

<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
  <a href="http://www.example.com/dresses" itemprop="url">
    <span itemprop="title">Dresses</span>
  </a> ›
</div>  
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
  <a href="http://www.example.com/dresses/real" itemprop="url">
    <span itemprop="title">Real Dresses</span>
  </a> ›
</div>  
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
  <a href="http://www.example.com/clothes/dresses/real/green" itemprop="url">
    <span itemprop="title">Real Green Dresses</span>
  </a>
</div>
Here's how this sample works:

On the first line of each

, indicates that the HTML enclosed in the
describes a breadbrumb. itemscope indicates that the content of the
describes an item, and itemtype="http://data-vocabulary.org/Breadcrumb" indicates that the item is a breadcrumb.
The sample describes properties of the item, such as its title and URL. To label properties, each element containing one of these properties (such as
or ) is assigned an itemprop attribute indicating a property. For example, .
Each breadcrumb item should appear in order, with the first item representing the top-level page, and the final item representing the parent of the current page.

Comments

Anonymous’s picture

subscribe

goz’s picture

Version: 6.x-2.x-dev » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new4.87 KB

I make a patch for 6.x-1.x to display microdata during custom_breadcrumbs generation.
I add also a settings page to choose if microdata have to be generate or not.

This patch works if you have only one breadcrumb on the page. For multiple breadcrumbs, microdata syntax is different.

goz’s picture

New patch :
I edit variable's name to get module's name.
I also delete variable in hook_uninstall

goz’s picture

Sorry i'm not very use to git.
So one patch to rule them all.

goz’s picture

Status: Needs review » Patch (to be ported)

No-one check this patch ?

goz’s picture

StatusFileSize
new6.01 KB

There is a notice caused by token because module called token_replace function with array argument instead of $text string.
A new patch resolve this

goz’s picture

Status: Patch (to be ported) » Needs review

Needs review

heyyo’s picture

Hi GoZ thanks for your patch !
it seems to be for 6.x-1.x. too bad i'm using 6.x-2.x now :-)

mr.j’s picture

For anyone else looking for this, you may as well just do it in your template.php.

eg:

function phptemplate_breadcrumb($breadcrumb) {

  $crumbs = '';

  if (is_array($breadcrumb) && count($breadcrumb) > 1) {
    $crumbs = '<div class="breadcrumb" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><ul>';

    // Change each link for Microdata support
    // from: <a href="/forum">Forums</a>
    // to:   <a itemprop="url" href="/forum"><span itemprop="title">Forums</span></a>
    foreach ($breadcrumb as $value) {
      $value = preg_replace('/(<a[^>]*>)(.*)(<\/a>)/i', '$1<span itemprop="title">$2</span>$3', $value);
      $value = str_replace('<a href', '<a itemprop="url" href', $value);
      $crumbs .= "<li>$value</li>";
    }

    $crumbs .= '</ul></div>';
  }

  return $crumbs;
}
creatile’s picture

Thank you Mr j

Here is my working version for D7
Works with path_breadcrumbs module (But you need to disable the "Use module breadcrumbs render function" in the settings admin/structure/path-breadcrumbs/settings )

Add this in template.php :

function themename_breadcrumb($variables) {

$breadcrumb = $variables['breadcrumb'];
$crumbs='';
  if (!empty($breadcrumb)) {
      $crumbs = '<nav class="breadcrumb">';
      foreach(
      $breadcrumb as $value) {
      
      $value = preg_replace('/(<a[^>]*>)(.*)(<\/a>)/i', '$1<span itemprop="title">$2</span>$3', $value);
      $value = str_replace('<a href', '<a itemprop="url" href', $value);
      $crumbs .= '<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">'.$value.'</div>';
      
      }
      $crumbs .= '</nav>';
    }
      return $crumbs;
}
gumol’s picture

creatile, thank you for your contribution. It works good.
You saved a lot of my time to figure this out! :)

sunward’s picture

subscribe

atobis’s picture

I'm trying to apply the creatile solution (#10) but it does not work.
I'm using Custom Breadcrumbs: 7.x-2.0-beta1 with taxonomy.
Do I have to apply some patch or configuration in addition to the changes in template.php?

Thanks in advance.

summit’s picture

Hi, With latest Custom Breadcrumbs I have the same problem I think as Atobis.
The Item value should be an url, and not a taxonomy like drinks/beer, but http://www.mysite.com/drinks/beer.

Does anybody know how to get this working?
greetings and thanks for your reply in advance, Martijn

lamp5’s picture

Status: Needs review » Closed (outdated)