Menu path in Pathauto

前端 未结 10 1107
天命终不由人
天命终不由人 2021-02-01 17:31

How do I get pathauto under Drupal 7 to generate a URL alias by the full menu path?

相关标签:
10条回答
  • 2021-02-01 17:35

    You'll need to install the contrib Token module as well -- although a lot of the features of Token are part of core in D7, some of the edge case tokens (like the full menu path of a given node) aren't provided by core automatically.

    With that installed, I believe that [node:menu-link:parent] or [node:menu-link:parent:url] should work.

    0 讨论(0)
  • 2021-02-01 17:36

    Just an update in case anyone comes across this with a more recent version of Pathauto/Token. This worked for me:

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

    0 讨论(0)
  • 2021-02-01 17:38

    Enjoy!

    [node:menu-link:parents:join-path]/[node:title].html

    0 讨论(0)
  • 2021-02-01 17:42

    This is the solution I use:

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

    It will separate parent menu items with a dash. That is what I need.

    0 讨论(0)
  • 2021-02-01 17:43

    If you're attempting to make aliases for pages that are 3rd level or deeper, for example:

    Home page
     > Level 1 page
       > Level 2 page
         > Level 3 page
    

    and you want the alias for Level 3 page to look like http://domain.com/level-1/level-2/level-3, I got it to work for me by setting my pattern to:

    [node:menu-link:parent:parent:parent:title]/[node:menu-link:parent:parent:title]/[node:menu-link:parent:title]/[node:title]
    

    Notice that I added :parent to the token, and for the first one I added it twice.

    0 讨论(0)
  • 2021-02-01 17:47

    I ended up using:

    [node:menu-link:parent:url:path]/[node:menu-link]

    Heavy caution though: If the node does not have a menu link, you'll end up without an automatically aliased page. On the bright side, this might make you aware of orphan pages. (Consider it a feature!)

    Note that using the pattern:

    [node:menu-link:url:path]/[node:menu-link]

    will only give the node's menu link, not that of the parent (which would be needed to reference the parent's path).

    Or the pattern: [node:parent:url:path]/[node:menu-link]

    throws an error in my instance of Drupal 7 about invalid tokens (even though I have the token module installed).

    0 讨论(0)
提交回复
热议问题