summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurits Lawende2012-10-05 09:52:40 (GMT)
committer Maurits Lawende2012-10-05 09:52:40 (GMT)
commit032dcea069ab1d212a0f78d8ae625cf1cce62329 (patch)
treeb405c79bfbfdbac0780c40623b98d1a54b4196a5
parentbab10b3d35433774be5cc24b4ae2377914c33d6b (diff)
Fixes for alias token:
1) Don't use in parent crumbs as it will set paths for new nodes to /add-content/.. 2) Force Hansel to keep the last item when generating the crumbs for the alias
-rw-r--r--hansel.actions.inc9
-rw-r--r--hansel.module18
2 files changed, 20 insertions, 7 deletions
diff --git a/hansel.actions.inc b/hansel.actions.inc
index bcd229a..d014cb5 100644
--- a/hansel.actions.inc
+++ b/hansel.actions.inc
@@ -281,7 +281,14 @@ 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']);
+ $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.
diff --git a/hansel.module b/hansel.module
index 9339800..d67630a 100644
--- a/hansel.module
+++ b/hansel.module
@@ -447,11 +447,17 @@ function hansel_get_config() {
/**
* Generate breadcrumbs.
*
- * @param bool $test Set test messages
- * @param bool $html Return the output in plain text rather than HTML
- * @return mixed Array with breadcrumbs or FALSE (means: leave with restore option).
+ * @param bool $test
+ * Save test messages.
+ * @param bool $html
+ * Return the output in plain text rather than HTML.
+ * @param bool $keep_last_item
+ * Force this function to keep the last item, even when the settings are set
+ * to hide it. This is used for the alias token.
+ * @return mixed
+ * Array with breadcrumbs or FALSE (means: leave with restore option).
*/
-function hansel_get_breadcrumbs($test = FALSE, $plaintext = FALSE) {
+function hansel_get_breadcrumbs($test = FALSE, $plaintext = FALSE, $keep_last_item = FALSE) {
$config = hansel_get_config();
extract($config);
@@ -589,7 +595,7 @@ function hansel_get_breadcrumbs($test = FALSE, $plaintext = FALSE) {
}
// Remove the last item if the "Hide last item" configuration option is set.
- if (variable_get('hansel_breadcrumb_last_item_hide', FALSE)) {
+ if (variable_get('hansel_breadcrumb_last_item_hide', FALSE) && !$keep_last_item) {
if ($count) {
!$test or _hansel_test_message(t('Removing last breadcrumb item (hide last item configuration option is set)'));
array_pop($breadcrumbs);
@@ -784,7 +790,7 @@ function hansel_tokens($type, $tokens, $data = array(), $options = array()) {
return array();
}
- $path = hansel_get_breadcrumbs(FALSE, TRUE);
+ $path = hansel_get_breadcrumbs(FALSE, TRUE, TRUE);
if (is_array($path)) {
$path = $path['breadcrumb'];
}