7

I have a contextual filter that is set to evaluate the "Raw value from URL" against my taxonomy term name. The issue is that a few of my taxonomy terms are two or three words long. This results in a URL like:

https://example.com/category/my%20taxonomy%20term

What I want is for my url to be:

https://example.com/category/my-taxonomy-term (but this currently returns no results).

Is there a way to use dashes instead of the %20 in a views contextual filter that uses the "Raw value from URL" setting?

5

Don't worry, Drupal won't leave you hanging with ugly urls.

1) Open your contextual filter in the admin interface.

2) Expand the "More" section at the bottom.

3) Check "Transform spaces to dashes in URL"

Terms like "my-taxonomy-term" will now be processed as "my taxonomy term"

Bonus: If you need that term to be capitalized for the page title, change "Case" to "Capitalize each word" (also in the "More" section).

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.