2

I've got a View with an Exposed Filter that shows Taxonomy Terms that are used to filter the content that's going to be displayed as the result.

It's a View that shows recipes based on the filters chosen by the user (Type of Recipe, Type of Meat).

When I submit the form, I get the following URL:

/recipes-view?type-of-recipe=all&type-of-meat=22

The last parameter shows the number 22, which is the Term ID for the value chosen. The URL has to contain the Term Name instead of the Term ID.

Can I change it via hook_views_query_alter() or is it needed to create a custom handler for that?

Thanks in advance.

0

There's no need to do this in code. You basically need to:

  1. Add relationship to taxonomy term via entity reference field (it would probably also work with term reference)
  2. Add exposed filter using this relationship (search for field Taxonomy Term: Term)

It works fine and you get URL, such as:

recipes-view?tid=vejuu

If you want to have an URL key type-of-meat, you can set it in More drop-down in you exposed filter configuration. The field name is Filter Identifier

I experienced problems with using features trying to prevent duplicates created by joining taxonomy terms.

  • Can you provide more details on how to add the taxonomy term via entity reference field? – Sam Oct 14 '17 at 10:59

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.