By Francisco Luz


2013-06-11 21:23:20 8 Comments

SCENARIO:

  1. I created taxonomy terms with 3 depth levels. Example:

    Term 1 ( Root )
       Term 2 ( Child of Root )
          Term 3 ( Child of Term 2 )
    
  2. In the URL Alias for my vocabulary I set:

    [term:parent:parent]/[term:parent]/[term:name]
    
    That successfully creates a path that looks like this:
    
    "http://mydomain.com/term-1" for the root term
    "http://mydomain.com/term-1/term-2" for the root's child term
    "http://mydomain.com/term-1/term-2/term-3" for the child's child term
    
  3. In my Content Type, I created a Term Reference field that forces the user to select the deepest term ( 3rd term down ) with the help of Simple hierarchical select module.


ISSUE:

When creating nodes, I would like to set the node's URL Alias to term-1/term-2/term-3/node-tile. I am having trouble finding the Replacement Pattern for doing just that.

Does path auto allow me to do that out of the box? If so, what pattern should I use?

2 comments

@Елин Й. 2013-06-11 21:39:40

Yes there is a token for that. Assuming the machine name of the Term Reference field in your content type is field_myterm, the pattern for the path should be:

[node:field-myterm:parent:parent]/[node:field-myterm:parent]/[node:field-myterm]/[node:title]

Notice the underscore in the field name is replaced with a dash in the token.

Edit: I just realized that these tokens come with Entity Tokens module which is included in Entity API module.

@Francisco Luz 2013-06-11 23:26:28

Thank you Елин Й. Both solutions, yours and Clive's, work as gold.

@Clive 2013-06-11 21:40:14

There are some advanced uses of tokens (not sure off the top of my head if that's just in the context of pathauto or not). You can get what you're looking for with join:

[node:field-name:parents:join:/]/[node:field-name:name]/[node:title]

You could also replace your term pattern with:

[term:parents:join:/]/[term:name]

Using that method your vocabulary can grow gracefully to 4 (or more) levels without having to change the pathauto pattern.

You'll need to go to admin/config/search/path/settings and set the Slash (/) option to "Do not Replace" under "Punctuation" for that method to work.

@Francisco Luz 2013-06-11 22:53:56

Ok, I am still having trouble. Please take a look at this screen shot here bit.ly/14vs8xu . It shows the available tokens for my taxonomy field under "Content Paths". Notice that tokens like [node:field-main-menu:parents... and [node:field-main-menu:name] is not available and sure enough drupal complains about it when I try to save. Non of those tokens seen on the screen shot actually work but [node:field-main-menu] which returns the deepest term item ( Term 3 ). Would you have a clue of what might bee the issue here?

@Clive 2013-06-11 23:15:04

Do you have the Entity API module installed? As @Елин Й. mentioned that's required, I forgot to add that

@Francisco Luz 2013-06-11 23:25:09

Yes I do have Entity API. I've just figured out what was wrong. My field was set to unlimited values. Now both solutions, yours and @Елин Й work beautifully. Thank you very much both of you.

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] How do I modify the URL to a taxonomy term?

3 Answered Questions

Show 404 on page for node path url instead of redirecting to it's alias

1 Answered Questions

Where in the MySQL database schema is the URL alias for a group relation?

1 Answered Questions

How to set alias pattern of node's source alias?

1 Answered Questions

[SOLVED] Tokens for taxonomy term parents in Pathauto

  • 2017-01-05 00:27:37
  • Scott Anderson
  • 2462 View
  • 2 Score
  • 1 Answer
  • Tags:   8 path-aliases

1 Answered Questions

[SOLVED] Pathauto and taxonomy

2 Answered Questions

How to set the url alias of a node created by Rules?

1 Answered Questions

[SOLVED] Create custom path alias when new user is added in drupal 7

  • 2015-08-19 06:14:30
  • Guru
  • 363 View
  • 0 Score
  • 1 Answer
  • Tags:   path-aliases

1 Answered Questions

taxonomy auto-path views path issue

Sponsored Content