1

How do I get the URL, not the link html for a taxonomy field in my view.

For Drupal 7 I found this ticket: How do I get the raw URL as a field in Views?

This mentions getting the content: path - but this doesn't show up as an option.

--- Updated ---

I am creating a block view, not sure that matters. I have no path option, I actually am not seeing any content in the field type options.

Block view field options

  • I am starting to think that this is a bug. – No Sssweat Apr 29 '16 at 5:07
  • There is a feature request to add an option to the Entity link Views field plugin to generate a raw URL: drupal.org/node/2810097 – MegaChriz Oct 3 '17 at 9:35
3

You can do the following.

  1. Add Taxonomy ID field too your view
  2. In your template or rewrite use the following as your url {{url('entity.taxonomy_term.canonical', {'taxonomy_term': tid})}} or {{path('entity.taxonomy_term.canonical', {'taxonomy_term': tid})}}
1

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.

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.