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.

2
  • drupal.stackexchange.com/questions/9332/… just follow the above link and check.
    – Sidharth
    Commented Oct 27, 2016 at 11:22
  • @Sidharth your comment is linking to QA on contextual filters, OP is trying to change a Exposed Filter Query string
    – Sam
    Commented Oct 14, 2017 at 10:58

1 Answer 1

-1

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.

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

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.