You are here

function crumbs_reduce_path in Crumbs, the Breadcrumbs suite 6.2

Same name and namespace in other branches
  1. 7.2 crumbs.module \crumbs_reduce_path()
  2. 7 crumbs.module \crumbs_reduce_path()

Chop off path fragments until we find a valid path.

Parameters

$path: starting path or alias

$depth: max number of fragments we try to chop off. -1 means no limit.

3 calls to crumbs_reduce_path()
crumbs_ParentFinder::_findParentPath in ./crumbs.trail.inc
_pathauto_CrumbsPlugin::findParent__node_x in plugins/crumbs.pathauto.inc
_path_CrumbsPlugin::findParent in plugins/crumbs.path.inc

File

./crumbs.trail.inc, line 59

Code

function crumbs_reduce_path($path, $depth = -1) {
  $fragments = explode('/', $path);
  while (count($fragments) > 1 && $depth !== 0) {
    array_pop($fragments);
    $parent_path = implode('/', $fragments);
    $parent_item = crumbs_get_router_item($parent_path);
    if ($parent_item && $parent_item['href'] === $parent_item['link_path']) {
      return $parent_item['link_path'];
    }
    --$depth;
  }
}