2

I have this page: https://www.meubelentheo.be/catalogus

On the top of this page, just below the title you will see links such as Babykamer, Bureau, Decoratie etc.

These are taxonomy terms in an exposed filter. I use the Views module together with Better exposed filter.

If you click on the first term Babykamer, you will see the URL changes to https://www.meubelentheo.be/catalogus?field_portfolio_tags_tid=34

What I want to achieve: rewrite the part after the ? to something like ?term=babykamer or even better, rewrite the whole querystring to catalogus/babykamer

I tried the Query paramters to URL module and this indeed rewrites the URL to but this is not what I want. I want the taxonomy term name to be shown in the URL.

Any ideas?

  • Are you using pathauto, maybe? See this. – Mołot Jan 3 '16 at 13:11
3

You can accomplish this look by using Contextual Filters instead of an exposed filter in Views. But this approach will involve several changes. In a nutshell you would need to:

  1. The list of tags on top would need to be a different (taxonomy) Views, embedded in the Header area of your catalogus View using Global: View area. In the taxonomy view, you will need to rewrite the output of the Taxonomy field (use "Rewrite results" in the taxonomy field) to a link that points to /catalogus/[field_portfolio_tags]

  2. Add a Contextual Filter to your catalogus View. Be sure to add the taxonomy field Portfolio tags to the list of fields in this View (you can hide it if you don't want it to display for every single product). Choose the taxonomy Content: Portfolio tags. Choose Display all results in When filter value is not in URL. In WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED choose Specify validation criteria. Validator: taxonomy term. Filter value type: term name converted to Term Id.

When you click on a taxonomy term in the embedded header View you will be redirected to /catalogus/name_of_tag. The Contextual Filter will assure that only products with that tag will be shown.

This should be it!

0

The use case "Filter my view results with the Term Name in my url" we are discussing here can easily be achieved with "Contextual filter by term ID" + the very old, stable and light "URL alias" feature. Easier and faster.

Please do note also on Drupal 8 this is even more complicated (follow on Druapl.org)

Url alias will make you work easier on both D8 and D7

enter image description here

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.