summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurits Lawende2012-09-13 15:35:44 (GMT)
committer Maurits Lawende2012-09-13 15:35:44 (GMT)
commitd003b3f89f2b8d15a639dd1552a1114ac28bc018 (patch)
tree0cff720e07a531a1236776969433132afe2fe5cc
parent92fcf32c048446e186e458997c459e377c799791 (diff)
Add functionality to find parents based on url aliases
-rw-r--r--hansel.actions.inc29
-rw-r--r--hansel_ui/hansel_ui.module7
2 files changed, 36 insertions, 0 deletions
diff --git a/hansel.actions.inc b/hansel.actions.inc
index a5059c4..97031ec 100644
--- a/hansel.actions.inc
+++ b/hansel.actions.inc
@@ -274,6 +274,35 @@ function menu_hansel_get_parent($path) {
}
/**
+ * Implements hook_hansel_get_parent().
+ *
+ * @param string $path
+ * @return array
+ */
+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'],
+ );
+ }
+ }
+ }
+ return FALSE;
+}
+
+/**
* Callback for the "add single link" breadcrumb action to generate the config form.
*
* @param array $arguments
diff --git a/hansel_ui/hansel_ui.module b/hansel_ui/hansel_ui.module
index 9e82d4f..022644c 100644
--- a/hansel_ui/hansel_ui.module
+++ b/hansel_ui/hansel_ui.module
@@ -202,6 +202,13 @@ function hansel_ui_settings($form_state) {
'#default_value' => variable_get('hansel_set_menu_name', TRUE),
'#description' => t('This is required for the \'leave original breadcrumbs\' option to work for pages which are not in the default menu. Turn this option off if you experience side effects.'),
);
+
+ $form['hansel_parent_lookup_paths'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Lookup url aliases when looking for parents'),
+ '#default_value' => variable_get('hansel_parent_lookup_paths', TRUE),
+ '#description' => t('Hansel is able to lookup parents based on url aliases. But this may cost extra database queries. You should disable this feature when not required.'),
+ );
return system_settings_form($form);
}