0
votes

I have created a view in Drupal 8 with a REST output. The view is configured to show taxonomy terms of a certain vocabulary. I have configured the view to use the "Fields" display so that I can choose which fields are shown.

The problem is that I can't find a way to show the alias path for a taxonomy term. This value is not present under a taxonomy term. It is present under "Content", but then the link goes to content inside the taxonomy. When I choose "Taxonomy term: Link to Taxonomy term", it does show the correct link. But that field also generates complete html (<a> tag) and I want just the link value.

There used to be a module called "Views Term Path", but that module does not support Drupal 8.

1

1 Answers

0
votes

Same problem, I solved it by doing:

  • Add a field "Taxonomy term: Term ID [hidden]" (make it hidden or not)
  • Ensure that this field is in first position (if not, rearrange the fields order)
  • Add a field "Global: Custom text"
  • Put "{{ path('entity.taxonomy_term.canonical', {'taxonomy_term': tid}) }}" (thx @steven) in the "Text" section in the settings modal of this field.

Original response: https://drupal.stackexchange.com/a/244092/78476