I'm sorry if this is documented somewhere, but it's been a long day and I can't seem to find the answer to something that should be super easy and obvious.

I have a views exposed filter that contains a handful of taxonomy terms and need to set the filter default to <any>. However the exposed filter always defaults to the first term following <any>. I have tried this with the "remember" option enabled and disabled, but it doesn't make a difference. The filter itself works great--just can't set the default to <any>.

Can someone give me a nudge? Thanks!

Comments

marcvangend’s picture

If I'm not mistaken, the 'Optional' checkbox does this, but only when you specify no filter values and do not select 'Limit list to selected items'.

scott.browne’s picture

This is correct, you just need to also use CTRL and clicky all the individual items in the list; specifically SELECT ALL. You will also need to uncheck required just above the label area to utilize any. This will give you "Any" and default as it.

Scott Browne
www.coverclubmedia.com

FrontBurner’s picture

This should be very easy but isn't. I still haven't figured out how to accomplish this in D6. If you select "Optional" it should default to "Any" and not whatever the first item on the list is. Users expect to see all results and then be given the ability to refine the results by selecting a taxonomy filter.

subscribing

FlymastaFlex’s picture

I cant find the right hook for it...

3duardo’s picture

Okay, so I came here looking for the same info. After noodling around a little more I found a solution that works for me.

My view now defaults to - Any - on each page render

My settings:

[Operator] = is one of
[Options] = uncheck all items

Then, at bottom, check [Optional] and [Force single]

Now if I can just figure out a way to display a message if the user selection option has no result to display :-)

johnhanley’s picture

3duardo, thanks for sharing your findings.

Use the "Empty text" input for the corresponding page view to define the empty results text.

-------------------------------------------------------

"If you don't read the newspaper you are uninformed;
if you do read the newspaper you are misinformed."
-- Mark Twain

3duardo’s picture

I do this for all other views when appropriate but went brain-dead on my first exposed filter view.
Thanks

gnosis’s picture

+1 for this solution. Note that you might not notice right away that it's working if you have "Remember" checked. But if you kill your session and reload the page, you should see that Any is now the default.

anou’s picture

Selecting "nothing" to see everything is finally so obvious ;-) Thanks for this solution. Works great !

David THOMAS
http://www.smol.org

joeeastham’s picture

I'm struggling with the same issue and cannot find the "uncheck all items" option you mention. Is that the correct label? Thanks.

joeeastham’s picture

I didn't realize you meant that you actually deselected all the options in the select field that contains the cck terms. This thread set me straight: http://drupal.org/node/339384#comment-1188047

Sorry. Sunday morning and no caffeine makes Jack a slow boy.

johnhanley’s picture

Yes, you are indeed correct. The solution to default an exposed filter to <Any> is to deselect all the options and leave "Limit list to selected items" unchecked.

gourav.yadav’s picture

This worked for me D7 .. :)

jct’s picture

The only drawback I can see from this solution is that there are cases where you do not want all items to show in the list (ie content types that aren't available to all users).

jweedman’s picture

Saved me a bunch of time! Seems obvious when you hear how to do it!

-jweedman

gregaltuna’s picture

ROCK! Thanks for this A+++++ solution. So simple, yet so tricky.

Let me explain something to you. Um, I am not "Mr. Altuna". You're Mr. Altuna. I'm the Greg. So that's what you call me. You know, that or, uh, His Gregness, or uh, Greggie, or El Gregerino if you're not into the whole brevity thing.

thomasaaron’s picture

Thank you. I'd been fooling with that one for a couple hours. :(

bwoods’s picture

I was looking for the exact same thing ... didn't consider unchecking all of the options!

Bernardine’s picture

without the results on the first view? ie until the user actually selects and submits? When I hit my search page now I get all the items available beneath the search/sort boxes without any action from me.

mbworks’s picture

I also have a view that I want to remain empty until the user starts selecting - I don't want all the view results to appear automatically - is there a way?

mrlava’s picture

I create an Exposed filter for a Taxonomy: Term
I selected "is one of" and didn't check any of the boxes
Below that I checked "Force Single" and "Optional"
I click Update
I get the following error: An illegal choice has been detected. Please contact the site administrator.

I look at the log and it shows the following:

Type form
Message Illegal choice 0 in tid_1 element.
Severity error

If I save it, it then shows the default as < any> but is highlighted red and giving the error: An illegal choice has been detected. Please contact the site administrator.

I have an exposed filter above it that does the exact same thing... and works... I replicate it with anything (even the same term) and it gives me that error.

mrlava’s picture

this was a conflict due to the "better select" module, after uninstalling the module all worked well again

simonswiss’s picture

Note that you can also make it work while keeping better select (a great module!) enabled:

Go to Site Configuration ---> Better Select, from there you can tick the "Node form only" box, which displays better select checkboxes only on node forms.

That sorts the conflict! :-)

iancawthorne’s picture

Try renaming the Filter identifier to x or x2. This seems to do the trick for me. I was getting this problem with and without the better select module.

Hydrant Ltd
www.hydrant.co.uk

harryadu’s picture

Do you have any idea how to replace the label with the Filter name or any label of my choice? I actually want the filter to display the filter name as default instead of ""...

Thanks,

zinkzinkzink’s picture

Thanks djmystic82, changing the filter identifier from 'typ' to xx solved the issue for me!

fadgadget’s picture

worked for me too. thanks

masher’s picture

Or you can disable Better Select whilst setting up your views and then re-enable it when done.

I had to do it that way as I wanted checkboxes in User Profile taxonomy terms, with "Node form only" selected I lost the checkboxes as its not a node

mokargas’s picture

This simply doesn't work for me if I have an argument set to a taxonomy term from a different vocab. Defaults to the first term always.

I have two arguments. The first one is one of two terms, either male or female from a Gender vocab, the second is the Country subfield from a Location CCK.

If I set the exposed filter to another vocab (call it Boutique Categories) using Taxonomy: Term ID exposed filter it will always default to the first category in my Boutique Categories vocab, regardless if I select it or not.

Let's say I add the filter and not expose it, I get this query:

SELECT node.nid AS nid FROM node node  WHERE (node.status <> 0) AND (node.type in ('boutique'))

As soon as I expose it, with settings Force Single: On, Optional: On and Is one of: (no selection) the views query becomes

SELECT node.nid AS nid FROM node node  INNER JOIN term_node term_node ON node.vid = term_node.vid WHERE (node.status <> 0) AND (node.type in ('boutique')) AND (term_node.tid = 7)

You'll note that now term_node.tid = 7 exists, as if by magic. This is the tid of the first term in the term selection list, despite having nothing selected. Hence my view always defaults to this, and never defaults to Any.

Anybody have any ideas with this one? Is there something I'm not getting?

mokargas’s picture

I should note, this issue disappears if Force Single is set to off, and the query also changes. (ie multi-select box)

lucidD’s picture

Lucky number 7! My magic number was 40, kinda boring. Maybe if you rename the "Filter identifier" field in the exposed filter it will fix itself. For example changing "term_node" to "term_somethingelse". I'm not sure why, but this worked for me. However, if I change too many settings with "Force single" turned on, it starts doing the same thing, but with different numbers.

lucidD’s picture

Some more information on my settings in case it would be helpful:

Operator: "Is one of" (with everything selected)
Reduce duplicates: ON
Unlock operator: OFF
Optional: ON
Force single: ON
Remember: OFF
Limit list to selected items: ON

mexicoder’s picture

Limit list to selected items: ON

worked for me

nelslynn’s picture

These settings work, but only after I change the default "Filter Identifier" to something other than the default. Strange.

flashon’s picture

Same here, the above solutions didn't work for me until I changed the default "Filter Identifier".

gabrielZ’s picture

This worked for me

glynnr’s picture

Works great. Thank you Eduardo.

aleksandar.jakovljevic’s picture

Thank you, this helped me a lot. Solved me a problem I couldn't solve for a month!

tentonjim’s picture

Excellent painless solution. Thank you!

staceyrice’s picture

I had this problem in Drupal 7 and stumbled upon this thread. It's a little different, so I thought I'd post what I figured out from hints about D6 in this thread.

Add a filter and Expose filter to visitors.

Choose Single filter, give it a label, choose "Is one of" under Operator, and have no terms selected/highlighted in the "Select terms from vocabulary" box. The only option checked under the vocab box is "Display error message."

This setting defaults to in the dropdown list.

Nicolino77’s picture

Thank you for taking the time to summarize this for D7 users.

bramvandenbulcke’s picture

The above solution works perfectly. I could CTRL- or CMD-click to unselect the items in the box.

I wouldn't have found it without your help. Thanks!

colan’s picture

The ticket for this is #339384: Default option <Any> not set in exposed filters when terms are selected. With the new help text, this should be clearer.

qqboy’s picture

MariaWebIdeas’s picture

@staceyb Thanks for these instructions, worked great!

bulkseocontents’s picture

This is right, you simply need to additionally utilize CTRL and clicky all the individual things in the rundown; particularly SELECT ALL. You will likewise need to uncheck obliged simply over the mark region to use any. This will give you "Any" and default as it.

Samy-DT’s picture

Hello,
I have the same question but the answer given don't work for me, here are my filter exposed settings:

single filter type, labelled, is part of, no selection at all in the vocabulary box, not selection at all under this box.

However, the default radio button is the one just after the "any" button.

Any ideas ?
Bye