A lot of people wanted it, but the answer was, this is not possible.

This was wrong :)

Earl had an idea, here is the implementation
You need ctools to enable this exposed form plugin.

Comments

damienmckenna’s picture

@dereine, awesome work, will see if I can get some time to test this.

rburgundy’s picture

subscribing - Exciting stuff! It looks like it is working but I will continue to do more testing.

liliplanet’s picture

subscribe, thx!

infojunkie’s picture

subscribe

damienmckenna’s picture

Out of interest, are there any modules that can do this for D6/Views2?

infojunkie’s picture

@DamienMcKenna: Yes, Views Filters Selective in http://drupal.org/project/views_hacks. But it still fails in some cases.

infojunkie’s picture

Regarding the D6 functionality, the Views Filters Selective module in #6 is now fully functional and extensible.

@dereine, this module also supports filtering results from many-to-one tables that I don't think are supported in the patch here. I implemented this using an extra hook that can provide special code for handling specific cases (currently, only Taxonomy Term filter). If this were to be integrated within Views 3, I would go with a new overridable function in filter handlers that does this filtering (in addition to the standard filtering based on row fields that you provide here). If you're interested, you will find this code in views_filters_selective/views_filters_selective.module, hook hook_views_filters_selective_options.

merlinofchaos’s picture

Assigned: Unassigned » merlinofchaos
Status: Needs review » Needs work

The class needs doxygen.

The plugin needs a dependency on CTools so it doesn't whitescreen for people without CTools.

Need to make sure that it works when the view was never run. Reading through the code I think it does.

Otherwise this looks good, so a reroll with these changes should allow this to go in.

Assigning to self so I see the reroll faster.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new8.05 KB

See views_views_plugins in includes/plugins.inc

  if (module_invoke('ctools', 'api_version', '1.3')) {

Based on this the plugin would only be added if there is ctools enabled. So there will be no WSOD here.

Adding some doxygen to all exposed form plugins.

merlinofchaos’s picture

      if ($this->view->result && !empty($exposed_input[$identifier])) {

I found this made it really difficult to test. I also found that the way it's set up, there's no easy way to tell what this exposed form plugin is supposed to even do. We need to better describe what you're selecting. We need to make sure that we can say that we don't want the options available in some particular filters to be reduced.

I think we may have to work on some use cases here, because I don't know if we always want to have all options available at first, or not, and how we get back to the default state. I'm finding this part very confusing.

merlinofchaos’s picture

Assigned: merlinofchaos » dawehner
Status: Needs review » Needs work

Assigning back to dereine for more work.

Shadlington’s picture

Subbing

mandreato’s picture

Subscribe... very useful function, especially when used with autosubmit !
Is it possible to have a 7.x-3.x-dev version ?
Thanks In Advance !

neoglez’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

;-)

dawehner’s picture

Title: Restrict filters to the result » Restrict exposed filters to the result

Update title to be able to be found a bit better.

Marc-Antoine’s picture

Hello, just checking if this feature was committed or not, because it would really be usefull!

I can't offer much, but if someone makes a patch i'll test and provide the most feedback I can

thank you ppl!

Refineo’s picture

I would be glad to help testing this as well. Thank you!

mototribe’s picture

I would love to see this too. Thank you!

webroru’s picture

I have is version 7.x-3.3, but the terms are used in the filter is not reduced. Do I understand correctly, this patch removes the filter are the terms that return an empty result?

dawehner’s picture

The patch removes the elements, which isn't visible in the current result. You can already use the "Views Selective Exposed Filters" module in the views_hacks package.

dready2011’s picture

I am using CTools 7.x-1.1+0-dev and applied this patch (manually) to views 7.x-3.3+223-dev.
When i try to open a page using the view, the following error is thrown:
Failed opening required 'C:\xampp\htdocs\mysite/sites/all/modules/ctools/includes/form.inc' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\mysite\sites\all\modules\ctools\ctools.module on line 113

It comes from the line
ctools_include('form');
in views_plugin_exposed_form_restricted.inc

Any idea what is causing this? For what exact version of Ctools and Views was the patch made?

Thanks

mototribe’s picture

I'm interested in this as well. Will this be included in views eventually or do I need to rely on views hacks for it?

STNyborg’s picture

I have also tried to implement the feature, but cannot get it to limit exposed filtering to the view. If anyone has solved the puzzle it would be nice to hear how they solved it in detail.

mototribe’s picture

the views_hacks feature apparently only works for taxonomy term references.

STNyborg’s picture

I am trying to limit my exposed filters on taxonomy term references and so far have had no luck with the Views Hack module.

However, I came across this site http://www.examiner.com/article/drupal-show-only-used-terms-views-expose... where Andrey Samode apparently solved it with his detailed solution.

However this solution was written to Drupal 6.x, and I have tried to migrate the solution to 7.x without luck.

If anyone is up for a challenge and a go with migrating the solution to 7.x, please let me know.

marcoka’s picture

i applied it to the latest 7.x-3.x-dev as i am playing around with an exposed filter page.
you can not activate it
http://www.root.artwaves.de/screensnapr/1351432835-dW3FH0.jpg
select it, hit save, setting changes back to "Basic"

nikserg’s picture

Have same problem as e-anima. Subscribing.

demonde’s picture

This patch is still broken applying to the latest dev. It would be great to repair it.

mas0h’s picture

Issue summary: View changes

I can pay to get this patch working.

david_garcia’s picture

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

This functionality is provided by a contributed module.

#2162097: Views Selective Filters

dubcanada’s picture

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

That module requires you patch Views ( see patch at
https://drupal.org/files/issues/views-aggregation_problem-2159347-0_0.patch and Install.txt ). It is not a stand alone module, and as far as I am concerned should be functionality that is part of default views.

I completely disagree with david_garcia so I am going to reopen this.

dubcanada’s picture

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

Actually I take it back. There is another way people are planning on doing this task. So let's keep this closed.

https://www.drupal.org/node/2159347

david_garcia’s picture

The patch for core has already been commited to D8 and is about to make it's way to D7. Of course it would be better to have this functionality directly in core, but this is what we have for now and it's working quite well.