2

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

2
  • I am starting to think that this is a bug.
    – No Sssweat
    Commented Apr 29, 2016 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
    Commented Oct 3, 2017 at 9:35

2 Answers 2

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
2

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 and acknowledge you have read our privacy policy.

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