You are here

function path_breadcrumbs_page_alter in Path Breadcrumbs 7

Same name and namespace in other branches
  1. 7.3 path_breadcrumbs.module \path_breadcrumbs_page_alter()
  2. 7.2 path_breadcrumbs.module \path_breadcrumbs_page_alter()

Implements hook_page_alter().

File

./path_breadcrumbs.module, line 57

Code

function path_breadcrumbs_page_alter(&$page) {

  // See if current page has path breadcrumbs.
  $path = request_path();
  $path_breadcrumb = path_breadcrumbs_load_by_path($path);
  if (!$path_breadcrumb) {

    // Page may have path alias. We should check it!
    if (module_exists('path')) {
      $alias = path_load(array(
        'alias' => $path,
      ));
      if ($alias) {
        $path_breadcrumb = path_breadcrumbs_load_by_path($alias['source']);
      }
    }
  }

  // If object with breadcrumbs was loaded - build breadcrumbs.
  if ($path_breadcrumb) {
    $breadcrumbs = _path_breadcrumbs_build_breadcrumbs($path_breadcrumb);
    drupal_set_breadcrumb($breadcrumbs);
  }
}