0

So I created a nice gallery view and I wanted to add an exposed filter on tags so that my users could filter the content in it.

I created the proper tags ("photo" and "video" for example), created my tags filter using the "autocomplete" setting, checked the "Expose this filter" combobox and checked the "Grouped filters" radio.

Then, I added my two corresponding rows, giving them the respective values "is one of" => "photo" and "is one of" => "video", and left the default row to "Any". I have two nodes containing the tags "photo" for one, and "video" for the other.

Yet when I save everything and go to my gallery view, not only do I not get anything displayed even on the "any" filter, I get this error message:

Unable to find term: all

When I try to use my filters I don't get anymore things, but these messages:

Unable to find term: 1

Unable to find term: 2

These numbers are written in the "?field_tags_tid=" of my URL when I click my exposed filter buttons, but they are not even the corresponding tids of my two tags: "photo" is 11 and "video" is 12...

Even weirder: when on the admin side I change settings of my tags filter to "Dropdown" instead of "Autocomplete", this time I DO get the correct content displayed on my view for the "any" filter, but still nothing for the "Photos" and "Videos" filter, which still point to "?field_tags_tid=1" and "?field_tags_tid=2". But this time, no errors displayed.

Sadly, I cannot even try to put the right tid in my URL. I get the following error:

An illegal choice has been detected. Please contact the site administrator.

Is this drupal thing completely broken or am I just terribly unlucky?

2
  • Do I misunderstand your question or have you set up separate filteres for 'photo', 'video' and 'all'?
    – Triskelion
    Mar 18, 2013 at 17:13
  • I have created Grouped filters within the "Content: Tags" criterion. One row was already in the list, called "- Any -" and corresponding (I suppose) to the "all" tid somehow. (it appears as "?field_tags_id=all" in the url when Any is selected) then I added two other rows within the grouped filters list, called "Photos" and "Videos" and linked respectively to the "photo" and "video" tags
    – SylvainB
    Mar 18, 2013 at 17:22

1 Answer 1

0

Delete all your existing filters. I think you have misunderstood how they work.

Then add a single filter on the term reference field (field_tags?), expose to visitors, reduce duplicates, and make sure the filter is NOT required. Do not check anything else!

Submit, save your view, and you should have an exposed filter with the options '-Any-', 'Phpto' and 'Video'.

EDIT:

After much discussion, step by step:

  1. Go to /admin/structure/taxonomy and set up a vocabulary calling it whatever you wish (lets say 'media'). Then add terms to the vocabulary like 'Photo', 'Video' etc. If you have already done this, skip to step 2.

  2. In your content type, go to 'Manage fields' and add a term reference field to the type (lets call it 'Media') using the media vocabulary.

  3. Go to /admin/modules and disable Better Exposed Filters.

  4. Edit your view and delete all the current filters in the view. Save the view.

  5. Now add a filter on the taxonomy reference field (eg field_media). Click Add and configure fiter, on the first modal select 'Dropdown' and click 'Apply and Continue'.

  6. On the next modal, check 'Expose this filter to visitors, to allow them to change it'. The 'Filter type' should be 'Single filter'. Make sure 'Required' is not checked. Leave the operator as 'Is one of'. The only other box you should select is 'Reduce duplicates. Now click 'Apply' and save your view.

You will now see a dropdown list with all the terms in the vocabulary you created, plus the option -Any- at the top.

10
  • What should I put in my "vocabulary tags" field when I set up the filter? "photo,video"? When I do this, I just get a field-like filter, filled with the two keywords and no "- Any -". I want to use links with actual labels ("Photos" and "Videos"), but Better Exposed Filters fails when I set single filters and only displays error messages. (no filter options) So I had to set it back to Basic. Now the field-like filter does work... but that's not what I'm trying to achieve. I want to display different links to the visitors that apply specific tags to the filter of my view.
    – SylvainB
    Mar 19, 2013 at 13:43
  • If the Any label does not appear, then you have set the filter as 'Required'. You need to uncheck it. You did not mention the Better Exposed Filters module in your question. This module is in beta only. Be careful. First get your exposed filters working. Then try to make them pretty.
    – Triskelion
    Mar 19, 2013 at 13:54
  • Yes, sorry about that. I disabled it for now. Still no labels nor "Any" tag when "Required" checked. Just a combobox where you can enter stuff...
    – SylvainB
    Mar 19, 2013 at 14:38
  • Do not check required. If it is checked, you have to make a selection. If it is unchecked, then 'any' means 'no filter'.
    – Triskelion
    Mar 19, 2013 at 14:45
  • Sorry, I read "you have to set". It was unchecked in the first place and no suggestions for "Any". And I do not really understand how it should appear anyway, since "Any" is only a label that is set when I choose to use "Grouped filters", which really sounds like what I want to do: "Grouped filters allow a choice between predefined operator|value pairs"
    – SylvainB
    Mar 19, 2013 at 14:48

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.