drupal_set_breadcrumb

5 common.inc drupal_set_breadcrumb($breadcrumb = NULL)
6 common.inc drupal_set_breadcrumb($breadcrumb = NULL)
7 common.inc drupal_set_breadcrumb($breadcrumb = NULL)
8 common.inc drupal_set_breadcrumb($breadcrumb = NULL)

Sets the breadcrumb trail for the current page.

Parameters

$breadcrumb: Array of links, starting with "home" and proceeding up to but not including the current page.

8 calls to drupal_set_breadcrumb()

File

includes/common.inc, line 234
Common functions that many Drupal modules will need to reference.

Code

function drupal_set_breadcrumb($breadcrumb = NULL) {
  $stored_breadcrumb = &drupal_static(__FUNCTION__);

  if (isset($breadcrumb)) {
    $stored_breadcrumb = $breadcrumb;
  }
  return $stored_breadcrumb;
}

Comments

Include current page

How can I do to include current page?

As far as I can tell, this

As far as I can tell, this function hasn't changed since D6.

D6 example:

<?php
// Build Breadcrumbs
$breadcrumb = array();
$breadcrumb[] = l('Home', '<front>');
$breadcrumb[] = l('Topics', 'taxonomy/term/1');
$breadcrumb[] = l(drupal_get_title(), base_path() . request_uri()); // Link to current URL

// Set Breadcrumbs
drupal_set_breadcrumb($breadcrumb);
?>

In D7, Views 3 you can use replacement variables in php

Just paste this code into your header area for the taxonomy view. The %1 is the replacement variable for the first argument - the Term name in this case. Presumably you don't want to link to the term if you are currently on the term page.

<?php
// Build Breadcrumbs
$breadcrumb = array();
$breadcrumb[] = l('Home', '<front>');
$breadcrumb[] = l('Topics', 'taxonomy/term/1');
$breadcrumb[] = %1 ;

// Set Breadcrumbs
drupal_set_breadcrumb($breadcrumb);
?>

You can do something like

You can do something like this in the template.php:

function myThemeName_breadcrumb($variables) {
  $breadcrumb = $variables['breadcrumb'];

  if (!empty($breadcrumb)) {
    // Adding the title of the current page to the breadcrumb.
    $breadcrumb[] = drupal_get_title();

    // Provide a navigational heading to give context for breadcrumb links to
    // screen-reader users. Make the heading invisible with .element-invisible.
    $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';

    $output .= '<div class="breadcrumb">' . implode(' › ', $breadcrumb) . '</div>';
    return $output;
  }
}

@floatyears note that the

@floatyears note that the title added (above) to the end of the breadcrumb will not be a link (to the current page itself)

Login or register to post comments