0

I have been wrestling with this for a number of days. I apologize if this has been asked elsewhere, I am not able to find the fix, or maybe I am just not thinking in an incorrect way to make this work. One of my exposed filters searches using "Content:Has Taxonomy Term", I use the dropdown not autofill. With that created, I pull up my settings for better exposed filters. I expose my filter as checkboxes. the checkboxes that the Better Exposed Filters creates adds a number value to each of the checkboxes, not the taxonomy term name. Is there a way I can manipulate the output of the Better Exposed filter to show the name as the value, not id?

  1. Here I create add a filter/filter criteria. you can see on the left I added a Content Has Taxonomy term (exposed) enter image description here

  2. Here you can see the criteria. I have clicked the "expose the filter to visitors" to allow the visitor to select how to filter. I click a couple options in the select list to show different predetermined options. and not shown, I select the option "limit list to selected items" enter image description here

  3. from the highlighted 1st image above, shows settings for Better Exposed Filters. I click the setting option, and for the display of that criteria, and for that filter, display filter as checkboxes. enter image description here

  4. After that, I can preview my checkboxes here. enter image description here

  5. If you inspect each of those checkboxes, you can see the value assigned to the checkboxes, is a number. enter image description here

I believe it to be the Taxonomy Term ID?...

  1. In this next screenshot, you can see the value from the checkbox represented as the same id.

enter image description here

This is where I get stuck... I want to show the term as the taxonomy term name, not id.

thanks in advance for your help!

0

1 Answer 1

1

This has nothing to do with Exposed filter settings, it's to do with what information is stored in the Taxonomy term Entity Reference field on your Content Type, and it's the term ID, not the term name.

So when you add the most ready-available Taxonomy Fields/Filters to your Content Views you will get the term ID.

Other Taxonomy term information (term name included) is stored in another database table and you have to add the Relationship for that particular field in order to pull information from that table into Views.

What you want is to add the Relationship for the Field on your content that stores the Taxonomy term reference. You can require the Relationship if you only want to see nodes in results where that field isn't empty.

After you add that Relationship you will get more options under Fields and Filters, one of those options is the Taxonomy term Name. They will use the Relationship by default since they can't be added to the Views without it.

Add the Name Filter to your Views and expose it. Adjust the Vocabulary settings and other options to your particular need.

6
  • I might be close with a solution similar to yours. From my view, I created a relationship to field_tags:Taxonomy term. in the contextual filter I have "(field_tags: Taxonomy term) Taxonomy term: Name" In Contextual settings "WHEN THE FILTER VALUE IS NOT AVAILABLE" i leave as the default. when I "WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED" I replace the title with the suggested replacement pattern arguments.name. I specify validator Taxonomy term name and mark the vocabulary as tags. Commented Dec 29, 2020 at 15:18
  • for my filter criteria I "(field_tags: Taxonomy term) Taxonomy term: Term (exposed)". I select a couple terms out of the Select List (the Taxonomy terms I am trying to reference), and Limit List to selected terms. Those results are still producing the id, not the name. Commented Dec 29, 2020 at 15:18
  • field_tags stores the term ID. You have to add the Name Filter instead to get the name to appear. You will see it on the Filters list after you add the Relationship for field_tags. The same for Contextual filter, needs to be the Name one that uses Relationship. Setting validator to Name on a field that stores ID won't work.
    – prkos
    Commented Dec 29, 2020 at 18:46
  • under relationship, I searched for Term, which produced "Taxonomy terms on node", and the option I chose, "Taxonomy term referenced from field_tags". once I choose Taxonomy term referenced from field_tags, I do have new a Name option under filter criteria that I select. When I select that, and expose the filter, I lose the option to enter values via the the original select box, I only have the option to enter values via an input. Is this the way it should function? Commented Dec 29, 2020 at 21:28
  • Yes, that is the way to do it :) Exposed filter for Name will offer the input field. The Contextual Filter for the Name can give you a Summary that lists all terms present in the results, as links, and then you click through to narrow down results to a particular term. Summary Contextual in a Block/Attachment can be used together with all results to produce something like Exposed filters that automatically present the available values. Try learning about the Summary option in the Contextual filter, there are answers here you can find with examples. Also try Selective Better Exposed Filters.
    – prkos
    Commented Dec 30, 2020 at 13:02

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.