You are here

function path_hansel_get_parent in Hansel breadcrumbs 7

Same name and namespace in other branches
  1. 8 hansel.actions.inc \path_hansel_get_parent()

Implements hook_hansel_get_parent().

Parameters

string $path:

Return value

array

File

./hansel.actions.inc, line 387
Hansel breadcrumb actions

Code

function path_hansel_get_parent($path) {
  if (variable_get('hansel_parent_lookup_paths', TRUE)) {
    $args = array();
    $i = 0;
    while ($arg = hansel_arg($i++)) {
      $args[] = $arg;
    }
    $path = implode('/', $args);
    $alias = drupal_get_path_alias($path);
    $alias = substr($alias, 0, strrpos($alias, '/'));
    if (!($path = drupal_lookup_path($alias))) {

      // The alias is probably a valid system path.
      $path = $alias;
    }
    if (!($parent_path = drupal_lookup_path($path))) {
      $parent_path = $path;
    }
    if ($item = menu_get_item($parent_path)) {
      return array(
        'path' => $parent_path,
        'title' => $item['title'],
      );
    }
  }
  return FALSE;
}