You are here

function breadcrumbs_by_path_page_build in Breadcrumbs by path 7

Implements hook_page_build().

File

./breadcrumbs_by_path.module, line 37
Creates a breadcrumb trail based on the current aliased path.

Code

function breadcrumbs_by_path_page_build(&$page) {
  $use_breadcrumbs_by_path = TRUE;

  // Start with getting the current URL
  $path = current_path();
  $uri = drupal_get_path_alias($path);

  // If this path is within the excluded paths, do not show the breadcrumb.
  $to_exclude = variable_get('breadcrumbs_by_path_exclude_paths');
  if ($to_exclude) {
    if (drupal_match_path($uri, $to_exclude)) {
      drupal_set_breadcrumb(array());
      $use_breadcrumbs_by_path = FALSE;
    }
  }

  // Also check that this path isn't within the 'core breadcrumbs' list.
  $core_breadcrumbs = variable_get('breadcrumbs_by_path_core_paths');
  if ($core_breadcrumbs) {
    if (drupal_match_path($uri, $core_breadcrumbs)) {
      $use_breadcrumbs_by_path = FALSE;
    }
  }
  if ($use_breadcrumbs_by_path) {

    // build a breadcrumb trail and set the breadcrumb
    $trail = _breadcrumbs_by_path_build_trail($uri);

    // If the setting is enabled, add the current page title to the end of the
    // trail.
    if (variable_get('breadcrumbs_by_path_current_title')) {
      $trail[] = '<span class="active active-trail">' . drupal_get_title() . '</span>';
    }
    drupal_set_breadcrumb($trail);
  }
}