Currently, menu trail tokens (mostly used in pathauto configuration) are built using the titles of menu item parents. Often, however, the parent item has a path alias that differs from the menu titles. E.g., a parent item may have an alias built with CCK field tokens or manually coded.

The attached patch adds a new token, ['menu-trail-parent-alias']. This token will be set to the alias (or, if there is no alias, the original path) of the menu trails parent item of the node's type.

CommentFileSizeAuthor
#1 menu-trails-parent-path-token.patch1.42 KBnedjo

Comments

nedjo’s picture

StatusFileSize
new1.42 KB

Patch.

sun’s picture

Status: Active » Needs review
+++ menutrails.module	19 Feb 2010 19:45:13 -0000
@@ -359,6 +359,17 @@ function menutrails_token_values($type, 
+      $alias = drupal_get_path_alias($href);
+      $tokens['menu-trail-parent-alias'] = check_plain($alias);

@@ -367,6 +378,7 @@ function menutrails_token_list($type = '
     $tokens['menutrails']['menu-trail-parents-path-raw'] = t("The menu trail leading up to but NOT including the node -- RAW");
     $tokens['menutrails']['menu-trail-parents-path'] = t("The menu trail leading up to but NOT including the node");
+    $tokens['menutrails']['menu-trail-parent-alias'] = t("The path of the node's menu trail parent");

Hm - why an alias and not the path?

Powered by Dreditor.

nedjo’s picture

The main use I have in mind is for pathauto, where we want aliases and not system paths.

Say I have a panels node with the title and menu item title "My landing page for articles." I don't want such a long alias, so rather than using a title token I manually set an alias of "articles". I set this node's menu item as the menutrails parent for nodes of type article.

Now I can configure pathauto for articles to use ['menu-trail-parents-path']/['title-raw']. If I create an article with the title "Some article", if we used the system path for the alias, we'd get node/123/some-article. By using the alias, we get what I want: articles/some-article.

Xart’s picture

Thanks for ptach. I'd like this feature to include to de module.

It's useful...

Xart’s picture

I'd try it and not function for me...

Has anyone using this patch?

SophieG’s picture

Thanks it's working !!

alexgreyhead’s picture

Unless I'm doing something wrong, this isn't working for node types which don't have a default parent set in the menutrails settings; I was hoping it would be able to pick up the path of the page's parent according to the menu system, but that's probably a project for another day. Oh well :)

linneawilliams’s picture

This patch doesn't seem to be working for me. I'd like to use the node's parent's path as the base for the automated alias. Like so:

[menu-trail-parent-alias]/[title-raw]

And the [menu-trail-parent-alias] can be a hand-written/arbitrary URL.