0

I've read these questions:

But it did not help.

My Drupal version is 9.1.9. I have views displaying Taxonomy terms. Each taxonomy term has fields, for example "Genre". I have 16 different genres with "key|value" type.

I have exposed filter, based on genre field. I've added this field to Contextual filters and override the title, when filter value is in URL.

But!

  1. If there is no value in URL title displays "All", but it should display default view title.
  2. If filter is applied and there is value in URL, title displays field's KEY, but not it's VALUE, for example "2" (not the name of the genre).

What am I doing wrong?

1
  1. Did you enable the override title under Exceptions when the Display all results for the specified field is chosen under When the filter value is NOT available? Then it's doing what it's supposed to do, that override is only for the Exception, and you most likely have the value All there. Turn that title override off, and the default Title will be shown in the case when there is no argument for the filter.
  2. List fields only store key, not the value! That is why the Contextual is using and showing they key. If your value isn't complex maybe you can use it as the key as well? You don't need to enter both key and value into Field settings, if you enter only one it will be used as both the key and value. If you're dealing with phrases you can maybe construct the keys with "-" or "_" and keep the values properly capitalized. This will give you predictable Contextual filter arguments.
6
  • 1) Title override has no impact if I choose to "Display all results", view just shows standard title. If I choose "Provide default value" it shows "All", ignoring title override under exceptions again. – bigboy Jun 15 at 14:30
  • 2) In field settings is says that "There is data for this field in the database. The field settings can no longer be changed". So if I change it i will lose all data. And moreover, my main site language is not English, so there might be some path issues with filters if i remove "key|value" and replace it with just "value"? – bigboy Jun 15 at 14:32
  • 2) "List fields only store key, not the value!" but how is it showing correct values in filter dropdown then? If it's possible to show it on page, then it is rendered somehow, why is is so difficult to put it in title? I'm so confused... – bigboy Jun 15 at 14:34
  • 1
    1) update the Q with info on where you override the title under default value (screenshot)? Validation is done below in the next section, not in the section where no argument is present. 2) Be careful with changing the field settings, I haven't tried it on a key|value field. If it's just expanding the number of values there I think you're safe even with the warning. Usually people ask about reducing the number of field values, you can search for those questions. 2) I couldn't find a way to show Value in Views Title. It's not impossible, but it may need custom coding to fix. – prkos Jun 15 at 16:41
  • Thanks for yor help! I've created new test select field with just values and it worked. Title is now showing correctly, but there is an issue with paths. For example it can be /?field_test_value=THIS+IS+FIELD+VALUE, but field value is not in english and it causes some issues, for example when pasting url somewhere else. But thisis not related to this question. So now I need to override URL for filter pages in this view. – bigboy Jun 16 at 10:25

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.