You are here

function path_breadcrumbs_load_by_path in Path Breadcrumbs 7.2

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

Load enabled path_breadcrumbs by path.

Parameters

string $path:

Return value

array Array of path_breadcrumbs sorted by weight.

1 call to path_breadcrumbs_load_by_path()
path_breadcrumbs_load_variant in ./path_breadcrumbs.module
Load path breadcrumb variant for page url.

File

./path_breadcrumbs.module, line 479
Provide core functions for path breadcrumbs modue.

Code

function path_breadcrumbs_load_by_path($path) {
  $data =& drupal_static(__FUNCTION__);
  $pattern_needle = path_breadcrumbs_path_pattern($path);
  if (empty($data[$pattern_needle])) {
    if ($cache = cache_get(__FUNCTION__)) {
      $data = $cache->data;
    }
    else {

      // Do heavy work and cache results.
      ctools_include('export');

      // No need to sort variants by weight because path_breadcrumbs_load_all()
      // already sorted all data.
      $result = path_breadcrumbs_load_all();
      foreach ($result as $path_breadcrumbs) {
        if (empty($path_breadcrumbs->disabled)) {
          $pattern = path_breadcrumbs_path_pattern($path_breadcrumbs->path);
          $data[$pattern][] = $path_breadcrumbs;
        }
      }
      cache_set(__FUNCTION__, $data, 'cache');
    }
  }
  return isset($data[$pattern_needle]) ? $data[$pattern_needle] : array();
}