When using Views Filter Selective with taxonomy terms, it's great that I only see the terms that have been actually used. However, when I click on a term in the exposed filter, all the other terms disappear. It's not such a good UX if the user has to click All (or Any) to see the other terms again.

Sorry if this is a duplicate, but I didn't find a request like mine.

Comments

papagrande’s picture

Status: Active » Needs review
StatusFileSize
new771 bytes

I rolled a patch to change just one line so that the view that builds the exposed filter uses 'all' as its own filter instead of the exposed filter of the parent view. Simple, but it does what I need.

srgk’s picture

that's really helping, thanks!

can you please give me an idea on how to remove initial filtering on the selective filter when the view is loaded with some contextual filter? because the selective filter then is limited to the results corresponding to the contextual filter, while i want initially a complete selective list, which now shows only when i remove the initial contextual filter with the exposed filter checkbox (i have them synced).
thanks to your patch, if i later select some filters, the selective list stays complete.

srgk’s picture

i created a feature request http://drupal.org/node/1732806

Macronomicus’s picture

Status: Needs review » Reviewed & tested by the community

Cheers... patch in #1did the trick.

jpstrikesback’s picture

Title: Show All Selective Filters Even When One Is Selected » Fix to Show All Selective Filters Even When One Is Selected
Category: feature » bug

Thanks PapaGrande, working here! This is actually addressing buggy behaviour as when you have multiple exposed filters and one returns a validation error the selective filter returns no results and shows the default state of "Actual values...", this allows other filters to have errors without killing the selective filter. Good to commit IMO.

jpstrikesback’s picture

Status: Reviewed & tested by the community » Needs work

Quick update:

In further testing (on new views which didn't have the options cached in the static $result) I found that the initial value for the option should be set to 'All' as well as the set_exposed_input performed in the patch above:

  function get_value_options() {
    $this->value_options = array(0 => t('Actual values will be available at run-time'));
    if (empty($this->view->selective_oids) && !empty($this->view->inited)) {
      $handler = _views_filters_selective_get_handler($this->definition['proxy']);
      $oids = $this->get_oids();

becomes:

  function get_value_options() {
    $this->value_options = array('All' => t('Actual values will be available at run-time'));
    if (empty($this->view->selective_oids) && !empty($this->view->inited)) {
      $handler = _views_filters_selective_get_handler($this->definition['proxy']);
      $oids = $this->get_oids();
Jawni’s picture

Hey guys

Is there a chance I can use this functionality in only one of the exposed filters? Can't seem to figure it out, here

I basically have two filters: Category and Color

I want Category to allways display ALL the available values at all times

But then when you choose a Color, the values displayed are only the ones available at that level

Not sure if I made it clear. Any help?

papagrande’s picture

@Jawni, you likely could put in a hack that applies the selective filter for only certain exposed filters, but the better long term solution for the community would be to add in a toggle in the Exposed Filters modal that allows you to activate the selective filter per exposed filter, possibly similar to what Better Exposed Filters does.

gjones’s picture

When I applied the patch in post #1, I'm stuck with only one result for my selective exposed filter. The first option of the filter is always shown as the only result even when it shouldn't.

reatcory’s picture

#1 worked for me

Mark Vincent Verallo’s picture

In case you only want to be selective to certain criteria/filter, just copy the value of those criteria/filter to another variable and set the others to 'All'. Then pass that copy to $view_copy->set_exposed_input(). For example:

      if (!$view_copy) return NULL;
      $view_copy->selective_oids = TRUE;
      
      //start of my custom code to consider only certain criteria for selective filter
      $new_exposed_input = array (               
        //only copy this value if you want to only be selective for this criteria; others, set to all 
        'criteria1' => $exposed_input['criteria1'], 
        'criteria2' => 'All',
      	'criteria2' => 'All',
      	'criteria2' => 'All'        
      );
      
      $view_copy->set_exposed_input($my_exposed_input);

Hope this will help others..

undertext’s picture

Issue summary: View changes
StatusFileSize
new782 bytes

Just putting patch for alpha2 version.

subeda’s picture

Hi!
I have a problem similar to @Jawni. I have a web of comics. With three exposed filters: category, genre and author (taxonomy terms).
Selective Filters works great so when one of the exposed filters is selected the other only shows the avalaible options for the selected filter.
1. My problem is that the selected exposed filter doesn't show the full list anymore. I tried the patch but it applies to all exposed filters so always the three filters show all options.

What I'm trying without success is:
If for example I choose in Category: Adventure
The filters genre and author only shows the avalaible options for that selection (that's currently how selected filters area working great).
But if I try to select other from the same exposed filter, Category, only: -any- and the current selection are shown. I need that the current filter who All options.

2. Also I'm trying that if I make a selection in an exposed filter any other exposed filter are reset it's values. Do you know how to do this with Views Hacks or other module.

I'm trying to avoid: no results.
Thanks!

david_garcia’s picture

Please, help review this SandBox module:

https://drupal.org/sandbox/david_garcia_garcia/2162097

So we can decide if it can properly replace current module.

Thank you.

infojunkie’s picture

Status: Needs work » Closed (won't fix)

This module has been deprecated in favour of https://drupal.org/project/views_selective_filters. Please test there and reopen if necessary.

colbtron’s picture

Which file do you edit? Thanks.