function crumbs_reduce_path in Crumbs, the Breadcrumbs suite 7
Same name and namespace in other branches
- 6.2 crumbs.trail.inc \crumbs_reduce_path()
- 7.2 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()
File
- ./
crumbs.module, line 492 - Provides an API for building breadcrumbs.
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;
}
}