Hierarchical Select Pathauto termpath breaks with multiple vocabulary
The codebase I am working on uses hierarchical select with taxonomy to make it easy for editors to tag from nested terms. Pathauto is used to create the URL alias for the content type. We need both the parent and child terms in the URL, so use this token: [save-lineage-termpath-raw].
However, a problem occurs when you add a second vocabulary for the same content type. This breaks pathauto and it can not create the URL alias. Fortunately there is another token to save the day: [save-lineage-termpath-raw:vid].
[save-lineage-termpath-raw:vid]. only has output when terms are present for the vocabulary with the specified vid.
In this case, the vocabulary that I want to use with this path is the first one, which has an ID of 1. So the token is: [save-lineage-termpath-raw:1]
At this point, alarm bells start ringing because when you save the pathauto form, you will get a validation error.
The Pattern for all Car review paths is using the following invalid tokens: [save-lineage-termpath-raw:1].
Fortunately there is a patch for this already, which you can find here: http://drupal.org/node/1137056
If you don't know how to apply a patch, follow these steps:
- Save the patch file to your machine (in this case: /Users/blair/Sites/Drupal/patches)
- In terminal, navigate to the root of the hierarchical_select module folder (sites/all/hierarchical_select)
- Run the following command: patch -p0 -i /Users/blair/Sites/Drupal/patches/hs_taxonomy-token-list.patch
If you liked this, you'll love my book, Master Drupal Module Development.
"..the must have drupal developers book"
Feeling stuck with Drupal 8 module dev?
Get the free 7 lesson course that will help you get started today without feeling overwhelmed.
- Create Drupal modules with just a few commands using the Drupal Console
- Create custom pages
- Create custom blocks
- Create admin forms
- Demystify routers and controllers
- Bonus material