function path_breadcrumbs_load_by_path in Path Breadcrumbs 7
Same name and namespace in other branches
- 7.3 path_breadcrumbs.module \path_breadcrumbs_load_by_path()
- 7.2 path_breadcrumbs.module \path_breadcrumbs_load_by_path()
Load path breadcrumbs by path.
1 call to path_breadcrumbs_load_by_path()
- path_breadcrumbs_page_alter in ./
path_breadcrumbs.module - Implements hook_page_alter().
File
- ./
path_breadcrumbs.module, line 263
Code
function path_breadcrumbs_load_by_path($path) {
if (!$path) {
return FALSE;
}
// Build all path variants for wildcards.
$path_variants = array();
$path_vars = explode('/', $path);
// If more than one argument in a path.
if (sizeof($path_vars) > 1) {
$i = 0;
while ($i < sizeof($path_vars)) {
foreach ($path_vars as $key => $variant) {
if ($key == $i) {
$path_variants[$i][] = '*';
}
else {
$path_variants[$i][] = $variant;
}
}
$i++;
}
}
// Path templates for all pathes.
$path_variants[] = '*';
$path_variants[] = $path;
$variants = array();
foreach ($path_variants as $variant) {
if (is_array($variant)) {
$variants[] = implode('/', $variant);
}
elseif (is_string($variant)) {
$variants[] = $variant;
}
}
$path_breadcrumb = db_select('path_breadcrumbs', 'p')
->fields('p')
->condition('p.path', $variants, 'IN')
->execute()
->fetchObject();
if ($path_breadcrumb) {
$path_breadcrumb->titles = unserialize($path_breadcrumb->titles);
$path_breadcrumb->paths = unserialize($path_breadcrumb->paths);
}
return $path_breadcrumb;
}