function crumbs_get_router_item in Crumbs, the Breadcrumbs suite 7
Same name and namespace in other branches
- 6.2 crumbs.trail.inc \crumbs_get_router_item()
- 7.2 crumbs.module \crumbs_get_router_item()
Returns a router item.
This is a wrapper around menu_get_item() that sets additional keys (route, link_path, alias, fragments).
Parameters
$path: The path for which the corresponding router item is returned. For example, node/5.
Return value
The router item.
5 calls to crumbs_get_router_item()
- crumbs_debug_page in admin/
crumbs.debug.inc - crumbs_get_breadcrumb_data in ./
crumbs.module - Returns the breadcrumb data for the current page.
- crumbs_reduce_path in ./
crumbs.module - Chop off path fragments until we find a valid path.
- crumbs_TrailFinder::buildTrail in lib/
TrailFinder.php - Build the raw trail.
- MenuLinkPluginTest::testMenuLinkTitle in lib/
Drupal/ crumbs/ Tests/ MenuLinkPluginTest.php
File
- ./
crumbs.module, line 456 - Provides an API for building breadcrumbs.
Code
function crumbs_get_router_item($path) {
$normalpath = drupal_get_normal_path($path);
try {
$item = menu_get_item($normalpath);
} catch (Exception $e) {
// Some modules throw an exception, if a path has unloadable arguments.
// We don't care, because we don't actually load this page.
return NULL;
}
// Some additional keys.
if (!empty($item) && is_array($item)) {
// 'route' is a less ambiguous name for a router path than 'path'.
$item['route'] = $item['path'];
// 'href' sounds more like it had already run through url().
$item['link_path'] = $normalpath;
$item['alias'] = drupal_get_path_alias($normalpath);
$item['fragments'] = explode('/', $normalpath);
if (!isset($item['localized_options'])) {
$item['localized_options'] = array();
}
return $item;
}
}