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)

Set 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.

7 calls to drupal_set_breadcrumb()

File

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

Code

function drupal_set_breadcrumb($breadcrumb = NULL) {
  static $stored_breadcrumb;

  if (!is_null($breadcrumb)) {
    $stored_breadcrumb = $breadcrumb;
  }
  return $stored_breadcrumb;
}

Comments

Usage

<?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);
?>

Make sure you run the link

Make sure you run the link text through t() before setting the breadcrumb.

Beware if you do not check

Beware if you do not check 'Show home page link in breadcrumb' in your theme configuration under the breadcrumb settings, then the first element in your $breadcrumb array sent to drupal_set_breadcrumb will not be shown (ie. the first element is what drupal considers the home link on the theme config page).

Login or register to post comments