In dupal 6.x I used to use the token [menu-path-raw] as the default pattern for automated URL alias. However, in drupal 7 the token names have changed in drupal. I was wondering what is the drupal 7 equipalent of the token [menu-path-raw]. I tried several of the tokens but did not get the result I want.

Like: if I have a page B under A and C under B and then A so the path of c should be example.com/A/B/C (where A, B and C are Menu titles of respective pages)

Comments

aanjaneyam’s picture

Anybody please?

dave reid’s picture

Project: Pathauto » Token

You can use something like [node:menu-link:parent:path]/[node:menu-link:title] right now that will work as long as the parent menu link already has its alias assigned.

Pathauto for D7 is not going to provide any tokens. We're going to put them in Token module.

Also see #860082: BIKESHED: Token for a term or menu item's entire tree/hierarchy

aanjaneyam’s picture

There have been several DEV releases of token in the last few days. I was wondering if there has been any development in the above mentioned area.

dave reid’s picture

@amsri: Have you tried [node:menu-link:parent:path]/[node:menu-link:title] to see if that worked for you yet?

aanjaneyam’s picture

Well it works in few cases but doesn't in most cases. May be I might need to take some other preparatory/preliminary step which I am missing. What could i do to make it fully work on each node.

oakulm’s picture

I've been using this [node:menu-link:parent:url:alias]/[node:menu-link:title] and it works fine. Only problem is that you have to make sure every page is in the menu tree otherwise aliases get screwed bad...

theshanergy’s picture

#6 worked for me, which is strange because it seems like it should generate an additional forward slash on top level pages..

subscribing for an 'all-in-one' token like [menupath-raw]

davidfsmith’s picture

#6 works for me, but I really wanted to have the node language at the start, but prefixing the pattern with [node:language]/ causes (for example) lots of en/en/en at the start of the URL on a page three levels deep. There is probably a better way.

aanjaneyam’s picture

The option suggested in #2 doesn't seem to work any more. I get error on pattern settings page. The error is

The Pattern for all Article paths is using the following invalid tokens: [node:menu-link:parent:path].
The Pattern for all Basic page paths is using the following invalid tokens: [node:menu-link:parent:path].
The Pattern for all Course paths is using the following invalid tokens: [node:menu-link:parent:path].
The Pattern for all Department paths is using the following invalid tokens: [node:menu-link:parent:path].

dave reid’s picture

@amsri: See #7. Use [node:menu-link:parent:url:alias]

aanjaneyam’s picture

Oh! Sorry. Thanks for reply.

vegardjo’s picture

Subscribe, an equivalent for menu path would be much appreciated!

I've tried: [node:menu-link:parent:url:alias]/[node:menu-link:title]

which works fine for many pages, but for pages that fall under the front page you get this:

<front>/subpage	
<front>/subpage/subsubpage	

I've also tried [node:menu-link:parent:title]/[node:title] which solves the problem above, but doesn't work if you have more that one level of links..

knalstaaf’s picture

I'd say [node:menu-link:parent:title]/[node:menu-link:title] works best for me. It renders url's like domain.com/products/brand-new-product when having a menu structure like this:

  • home
  • products (menu title)
    • brand new product (menu title, not node title)
  • contact

(Drupal 7.2)

AndrewJarvis’s picture

Reading over this thread still begs the question from #6, is it still an issue that if a page does not have a menu item the path will be screwed?

Thanks!

kevinquillen’s picture

Some solution like #35 here (http://drupal.org/node/860082) is what I am looking for.

Edit: #35 works fine, and works for nodes a few levels deep in a menu.

mustanggb’s picture

Status: Active » Closed (duplicate)

None of the suggestions in this thread work for all situations
i.e. Things start to break for level 3 and higher menu or for sub-menu's of menu items that don't have the url you would expect (usually because they are themselves aliases of other pages)

Closing this in favour of getting a new token added along the lines of: http://drupal.org/node/860082#comment-4649530

dave reid’s picture

Note that due to change http://drupal.org/node/1265672, you should be using [node:menu-link:parent:url:path] instead of [node:menu-link:parent:url:alias].

sense-design’s picture

ressa’s picture

Version: 7.x-1.x-dev » 7.x-1.0

@Dave Reid, thank you. [node:menu-link:parent:url:path] isn't included under the "Replacement patterns", only [node:menu-link:parent:url]

But this works perfectly nevertheless: [node:menu-link:parent:url:path]/[node:menu-link:title]

BrianLewisDesign’s picture

Title: Equivalent of [menu-path-raw] » [node:menu-link:parents:join-path]

[node:menu-link:parent:url:path]/[node:title] -- this repeats the top level parent multiple times, for nth children in the menu. makes a mess. doesn't get the full heirarcy.

[node:menu-link:parent:parent:parent:parent:url:path]/[node:title] -- this gets the top parent only, with no repeats, down to the 4th child in the menu.

[node:menu-link:parents:join-path]/[node:title] -- perfect. this gets the whole parent menu hierarchy into the URL. that's what i was after.

mustanggb’s picture

Title: [node:menu-link:parents:join-path] » Equivalent of [menu-path-raw]
kevinquillen’s picture

[node:menu-link:parents:join-path]/[node:title] -- perfect. this gets the whole parent menu hierarchy into the URL. that's what i was after

How well does this work?

mario.awad’s picture

Version: 7.x-1.0 » 7.x-1.1

It works perfectly. However, I think it's more correct to use the following one as it uses the menu link instead of the node's title (which can be different or similar depending on the user's choice).

[node:menu-link:parents:join-path]/[node:menu-link]

Works very well under:
Drupal 7.14
Pathauto 7.x-1.1
Token 7.x-1.1.

Cheers.

m4rinos’s picture

Marvelous mario.awad! #23 solution works great!

georgemastro’s picture

stephesk8s’s picture

Issue summary: View changes

[node:menu-link:parent:url:alias] worked well for me to add the correct parent menu path to Custom Breadcrumbs. Without :alias, it was giving the domain twice i.e. website.com/website.com/parent-path. The :alias option was not in the Placeholder Tokens list but worked. Thank you for posting.