summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurits Lawende2012-09-13 15:46:31 (GMT)
committer Maurits Lawende2012-09-13 15:46:31 (GMT)
commitbab10b3d35433774be5cc24b4ae2377914c33d6b (patch)
treebfd0adbeb560c72f1cbce59ab6860cd8aad5bbcb
parentd003b3f89f2b8d15a639dd1552a1114ac28bc018 (diff)
Add functionality to find parents based on url aliases - should also work with system paths
-rw-r--r--hansel.actions.inc28
1 files changed, 13 insertions, 15 deletions
diff --git a/hansel.actions.inc b/hansel.actions.inc
index 97031ec..bcd229a 100644
--- a/hansel.actions.inc
+++ b/hansel.actions.inc
@@ -282,21 +282,19 @@ function menu_hansel_get_parent($path) {
function path_hansel_get_parent($path) {
if (variable_get('hansel_parent_lookup_paths', TRUE)) {
$alias = drupal_get_path_alias($_GET['q']);
- if ($alias != $_GET['q']) {
- $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'],
- );
- }
+ $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;