You are here

README.txt in Views taxonomy term name into ID 8

======================================================================
About
======================================================================

Drupal 8's version of Views is included in core, and very powerful.

However, its handling of taxonomy terms is missing some important
features, and can be confusing to configure properly.

The default contextual filter (aka "argument") for D8 taxonomy terms
is called "Has taxonomy term ID", which builds the most efficient
query to find content tagged with a given term.

In Drupal 7 and prior, there was an option on the "argument validator"
for taxonomy terms called "Term name converted to Term ID" that would
convert a term name into its corresponding term ID, exactly for use
with this contextual filter. That allowed you to use the most direct,
efficient query, but allow for human-readable URLs based on term names
instead of numeric IDs.

This module restores that functionality by providing a "Term name into
ID" option when configuring the validation for a Views contextual
filter, primarily for use with the "Has taxonomy term ID" contextual
filter.

======================================================================
Usage
======================================================================

1. Install as a normal Drupal 8 module using your favorite method.
2. Enable the module
3. Build a view using the 'Has taxonomy term ID' contextual filter.
4. Configure the contextual filter:
4a. Check the 'Specify validation criteria' checkbox.
4b. Under the 'Validator' selector, choose 'Taxonomy term name as ID'
4c. If your site has many vocabularies and the term name might not be
    unique across them, consider limiting which vocabularies to search
    by configuring the 'Vocabulary' checkboxes.
4d. Review other relevant validation settings (e.g. if you want to
    check access control, convert '-' to ' ' in the argument).
5. Save your view.
6. Rejoice.

NOTE: The conversion of a term name into its numeric ID assumes
there's only one term of a given name. If your site has multiple
vocabularies that have terms with the same name, you'll almost
certainly want to limit the validator to only search in a single
vocabulary.

If you have a vocabulary with duplicate names, you probably want to
either force the arguments in the URLs to be numeric IDs and not use
this validator at all, or consider using the 'Has taxonomy term ID
with depth' contextual filter and forcing the URLs to include a depth.

======================================================================
Related module
======================================================================

https://www.drupal.org/project/views_taxonomy_term_name_depth

However, that module takes a different approach, adds an entirely
separate contextual filter, and leads to more complicated
queries. Hence, the existence of views_taxonomy_term_name_into_id.

File

README.txt
View source
  1. ======================================================================
  2. About
  3. ======================================================================
  4. Drupal 8's version of Views is included in core, and very powerful.
  5. However, its handling of taxonomy terms is missing some important
  6. features, and can be confusing to configure properly.
  7. The default contextual filter (aka "argument") for D8 taxonomy terms
  8. is called "Has taxonomy term ID", which builds the most efficient
  9. query to find content tagged with a given term.
  10. In Drupal 7 and prior, there was an option on the "argument validator"
  11. for taxonomy terms called "Term name converted to Term ID" that would
  12. convert a term name into its corresponding term ID, exactly for use
  13. with this contextual filter. That allowed you to use the most direct,
  14. efficient query, but allow for human-readable URLs based on term names
  15. instead of numeric IDs.
  16. This module restores that functionality by providing a "Term name into
  17. ID" option when configuring the validation for a Views contextual
  18. filter, primarily for use with the "Has taxonomy term ID" contextual
  19. filter.
  20. ======================================================================
  21. Usage
  22. ======================================================================
  23. 1. Install as a normal Drupal 8 module using your favorite method.
  24. 2. Enable the module
  25. 3. Build a view using the 'Has taxonomy term ID' contextual filter.
  26. 4. Configure the contextual filter:
  27. 4a. Check the 'Specify validation criteria' checkbox.
  28. 4b. Under the 'Validator' selector, choose 'Taxonomy term name as ID'
  29. 4c. If your site has many vocabularies and the term name might not be
  30. unique across them, consider limiting which vocabularies to search
  31. by configuring the 'Vocabulary' checkboxes.
  32. 4d. Review other relevant validation settings (e.g. if you want to
  33. check access control, convert '-' to ' ' in the argument).
  34. 5. Save your view.
  35. 6. Rejoice.
  36. NOTE: The conversion of a term name into its numeric ID assumes
  37. there's only one term of a given name. If your site has multiple
  38. vocabularies that have terms with the same name, you'll almost
  39. certainly want to limit the validator to only search in a single
  40. vocabulary.
  41. If you have a vocabulary with duplicate names, you probably want to
  42. either force the arguments in the URLs to be numeric IDs and not use
  43. this validator at all, or consider using the 'Has taxonomy term ID
  44. with depth' contextual filter and forcing the URLs to include a depth.
  45. ======================================================================
  46. Related module
  47. ======================================================================
  48. https://www.drupal.org/project/views_taxonomy_term_name_depth
  49. However, that module takes a different approach, adds an entirely
  50. separate contextual filter, and leads to more complicated
  51. queries. Hence, the existence of views_taxonomy_term_name_into_id.