1

Our current url pattern is [node:menu-link:parents:join-path]/[node:title]. What we need is a way to not to include the parent menu link items and only include the child menu link items.

For example:

Current Menu Structure

The expected output is the following:

  • When Any menu link is placed at the same level as "Fourth level 1" (under Top level), it should be ".com/Second-level1/Third-level-1/Fourth-level-3"
  • Current issue is that the URL is generated as ".com/Top-Level/Second-level1/Third-level-1/Fourth-level-3"
  • We want to remove Top level, Top level 2, top level 3, etc removed from URL path alias.
  • Depending upon the placement of the menu link item, it should always contain the menu links 1 level above (if applicable)
  • The expected url pattern for third level 2 (under Top level/Second level 1) is ".com/second-level-1/third-level-2"

Updated:

I ended up write a custom module to call the hook_alter using the pathauto that just removes the first part of the URL before the node save event.

1

You can use this module https://www.drupal.org/project/pathauto with this you define the custom path use token

  • I am Path Auto already with the following pattern: [node:menu-link:parents:join-path]/[node:title]. The issue is that i do not want i do not want the links such as "Top Level", "Top Level 1", to show up in the URL path. I need assistance in removing the "top level" before the URL is generated. – sf_admin819 Aug 10 '16 at 18:37
1

You might be able to get this to work using the Rules module, together with the Path Rules module, using an approach like so:

  • Rules Event: around the time a node is saved (or updated, etc).
  • Rules Condition: use Path Rules which provides various Rules Conditions "for checking the URL against a given string" (check this module's project page for examples of such checking). It seems that checking your URL patterns should be straight forward with this module.
  • Rules Action: use the "Create or delete a node's URL alias" action to change the URL alias. This Rules Action is similar to using the Pathauto module, you can use tokens to create an appropriate path.
  • I tried that, but i noticed that when i select create or delete a node's URl alias, i am asked to enter the language, which will not work. I need the ability when the node is saved and before it is entered into the db, i need to take the given url path alias and alter it by removing any menu link item i don't want. – sf_admin819 Aug 10 '16 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.