Well, posting a proposal.
I have (over)commented the code.
The taxonomy (with depth, views_filters_selective_handler_filter_term_node_tid_depth) does not work jet.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aristeides’s picture

so... everything BUT the taxonomy is working??

neoglez’s picture

You should be answering your self to that question.

Jerome F’s picture

Thank you for posting @neoglez!

aristeides’s picture

started testing, reporting any bugs I find along the way.

Using it with node reference fields ( http://drupal.org/project/references ) I received the following errors:

Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined index: filter-status in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 124 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined index: views_handler_filter_in_operator in views_filters_selective_exposed_form_plugin->get_reducer_handler() (line 221 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined index: views_handler_filter_in_operator in views_filters_selective_exposed_form_plugin->get_reducer_handler() (line 221 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).

Jerome F’s picture

I second that using taxonomy fields (no reference fields here):

Notice: Undefined index: filter-status in exposed_form_alter() (line 124 of (...)/sites/all/modules/views_hacks/views_filters_selective/views_filters_selective_exposed_form_plugin.inc). 
Notice: Undefined index: location_handler_filter_location_country in get_reducer_handler() (line 221 of (...)/sites/all/modules/views_hacks/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined index: nid in pre_render() (line 83 of (...)/sites/all/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc)

Using location country field only and avoiding taxonomy, the results are not limited. All the countries still appear in the select list. But no notices. I guess it's just not taken into account by views filters selective.
Limit "Location: Country" values to result set is checked though

Which field type is currently working?

@neoglez I wrote that I asked a php developper to help me, but unfortunately he isn't a drupal developper and he got lost in drupal's module developement. Sorry for that, appart from testing I will not be able to provide much help here.

neoglez’s picture

The error
Notice: Undefined property: stdClass::$nid in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 115 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
and
Notice: Undefined index: filter-status in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 124 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc)
DON'T concern this module. If you install the latest (dev) version of node reference the error desapear (all views MUST have a base_field property).
Regarding the error Notice: Undefined index: views_handler_filter_in_operator in views_filters_selective_exposed_form_plugin->get_reducer_handler() (line 221 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
Notice: Undefined index: views_handler_filter_in_operator in views_filters_selective_exposed_form_plugin->get_reducer_handler() (line 221 of /var/www/html/sites/all/modules/views_filters_selective/views_filters_selective_exposed_form_plugin.inc)
read the comments on the code (you must implement hook_views_filters_selective_handler) becouse this module provides an API.
Good luck ;-)

neoglez’s picture

@Jerome, It's Ok, i'm beeing sponsored ;-)
Testing is great.
On the other hand only taxonomy filters (objects of the class views_filters_selective_handler_filter_term_node_tid ) are supported out of the box at the momment. Theoretically (i haven't tested this) a developer should be able to implement hook_views_filters_selective_handler for the filters that he wants, that's the power of the API (a litter like implemeting this module to hook into views).
When i find time i'm gonna add suport for more types of filters.

Jerome F’s picture

1) That's right it works for one taxonomy field now, which is awesome !

2) It gets more complicated when using more than one taxonomy filters, just because on the first page view, all the filters are set on the first taxonomy term available, even if it's not an available term, therefore I get several messages:
An illegal choice has been detected. Please contact the site administrator.
then I select some terms, If I find an available term it's working fine.
The same thing happens when I hit reset if I enable the reset button.

3) Apparently there's no way to leave the select field on any now, is this by design? Isn't it possible to let the user leave a select list blank, when using more than one filter?

4) Side note it's important to uncheck "remember las select choice" - this seems logical. If not you have to deal with: An illegal choice has been detected. Please contact the site administrator.

5) What do you mean by Undefined index: filter-status and Undefined index: filter-type notices don't concern this module? I don't have nodereference filter and still:

    Notice: Undefined index: filter-status in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 124 of (...)/sites/all/modules/views_hacks/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).
    Notice: Undefined index: filter-type in views_filters_selective_exposed_form_plugin->exposed_form_alter() (line 124 of (...)/sites/all/modules/views_hacks/views_filters_selective/views_filters_selective_exposed_form_plugin.inc).

There's no way to reproduce the other notices mentionned above, with only taxonomy filters checked. You've made your point.

Jerome F’s picture

about point 2) in last comment first screenshot is on page view, second screenshot is with an user selected term. If you refresh the page, you're back to first screenshot.

first URL :
http://exposedfilters.localhost:8082/restaurants
second URL
http://exposedfilters.localhost:8082/restaurants?field_business_catering_tid=12&field_business_ambiance_tid=18&field_business_type_tid=3&field_business_prices_tid=7&city=&country=All

So the best thing would be a default behavior for the view with - any - selected for each filter when you first display the page or reset the view filters, it would correct this issue and provide an expected feature for this kind of widgets.

neoglez’s picture

Assigned: neoglez » Unassigned
Status: Needs review » Active
FileSize
27.95 KB

@Jerome F Thanks for the info. It was VERY helpfull.
The problem is when the configured filter ID is other than the default (field_business_catering_tid, etc vs tid, tid_1, etc. in you description)
The display and the the view object don't update their filter's index but the $form_state and $form contain the id configured y the user-admin, maybe i file a bug/feature request report in views.
I had noticed the 'Ilegal choice' error and i was thinking in the right way to handle it becouse i was avoiding overriding the views_exposed_form_plugin::render_exposed_form function (there is no way to hook in the form rendering process other than that) but apparently with some changes i'm not seeing the error although i'm not sure if it is completely gone.

4) Side note it's important to uncheck "remember las select choice" - this seems logical.

I agree with this, but (remember the DAU theory) we should handle it, the same happens with 'required', anyway if these options are checked some logical problems arise although no php or drupal errors (for 'required' i had to re-login).
I'm posting what i find a very stable release ;-) at least in my controlled enviroment as a patch against the views_hacks D7 branch (only reachable through git).

  • Added some error handling.
  • Added _tid_with_depth filter selective handler support. At the momment Content: Has taxonomy terms (with depth) (exposed) is not working but as soon as this is resolved i will implement the whole feature(see the comments in code) so right now the handler is just falling back to the regular Content: Has taxonomy terms (working with taxonomy is a challenge), so be aware that the query is gonna be built over the taxonomy_index table, therefore if you have a term that has not been assigned to a node, you can get the 'Illegal choice' error, it wouldn't be very logical anyway to give the user the posibility of choosing a term when nothing is comming out (again here the DAU thing), and of course only node-entities are supported (entities using the taxonomy_index table).
  • Added the 'hide if empty' option.

Testing help is wellcome, if problems are found change the status to needs work, if you find it OK then to RTBC.

neoglez’s picture

Assigned: Unassigned » neoglez
Status: Active » Needs review

I'm taken over this one.

Jerome F’s picture

Assigned: Unassigned » neoglez
Status: Active » Needs review
FileSize
192.01 KB
28.93 KB

So in the meantime (befor this is taken into account in views) what should we do use default machine names for taxonomies? My view is still displayed as in the screenshot.
What about the - any - choice? Is it doable?

In the attached patch, I just added some cleanup, you need to provide @file blocks and to use two spaces instead of tabs. The coder module can help you to cleanup your code.

by the way what's the DAU theory?

neoglez’s picture

FileSize
28.65 KB

Patch for the 'illegal... ' error.
Let's let the -any- as a feature request until this have been marked RTBC and maybe reviewed by infojunkie.

Jerome F’s picture

Thank you.

Is there a problem using a menu link to the view page like this: www.example.com/restaurants
Then there's nothing in the url to trigger views filters selective like in: www.example.com/restaurants?field_business_catering_tid=11&field_busines...

Probably that's why the illegal choice hapens on first page view and page refresh. What do you think?

neoglez’s picture

I'm sorry, i don't understand very well what you mean, so:
Q: Is there a problem using a menu link to the view page like this: www.example.com/restaurants
Then there's nothing in the url to trigger views filters selective like in: www.example.com/restaurants?field_business_catering_tid=11&field_busines...?
A: NO, there should be no problems, the $_GET parameters (?field_business_catering_tid=11&field_busines...) are set and handle (yeah!) by views, you can assign the url/uri/path that you want to your views (it must be a PAGE DISPLAY though).
Q: Probably that's why the illegal choice hapens on first page view and page refresh.What do you think?
A: NO, after applying the patch in #13 you should get NO ERRORS. The VFS module just takes action if there is a USER INPUT (in the first page view there is no user input). Try to re-login, clear cache (drupal & views) and/or rebuild the view. I tested this under two not so controlled different enviroments (a local win PC and a Debian dev server) and it works just great.

Remenber: if (everything_ok) {issue_status = RTBC} XD

Jerome F’s picture

Status: Needs review » Reviewed & tested by the community

@neoglez: Oh yes, sorry, I had to CHECK the require checkbox ! That was it ! You did a very good work on this, than you!

I can confirm it works if :
- Require is checked (in the taxonomy term exposed filter's configuration)
- Show hierarchy in dropdown in unchecked (in the taxonomy term exposed filter's settings)
- You use taxonomy term exposed filters only, but you can use more than one of them which is great!

Hide if empty works OK!

For further improvements, the main feature requests in my opinion are:
1) Other filters:
I tried to use a country exposed filter as well but this is wired, if you select Luxembourg, it actually hides the nodes with Luxembourg instead of displaying them only, so there's a feature request for compatibility with other exposed filters but we have already your answer about in #7
2) filter not required (the - Any - option)

neoglez’s picture

Thanks!!
The Community is just great ;-)

infojunkie’s picture

Everyone: thanks for your efforts to port and test this. Much appreciated.

@neoglez: Would you like to participate in Views Hacks as co-maintainer for the D7 branch?

paulgemini’s picture

subscribing

neoglez’s picture

@infojunkie
Yes! :-) I like this module very much.
...and we must hurry: D8 is comming.

infojunkie’s picture

@neoglez: Thanks for your help! I gave you maintainer access to the module and added a 7.x-1.x tag. Go wild :-)

neoglez’s picture

Ok! Let's go! ;)

infojunkie’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
neoglez’s picture

Status: Reviewed & tested by the community » Needs work

...have to clean the patch (right indent) and maybe (it should be easy) add all functionalities from _plugin_exposed_form_required (just inheriting from the right class ).

neoglez’s picture

As described in #24 -> Done!
This deserves to be commited.
...and coder is not complaining :-)
From this point on please file a bug, feature request, etc. report against the 7.x-1.x-dev version.

neoglez’s picture

Status: Needs work » Fixed

Commited to 7.x-1.x.

alexbern’s picture

Neoglez, you rock!

Jerome F’s picture

+1 to certify to rock neoglez!
I opened new feature requests, following #16, to clarify the issue queue.
http://drupal.org/node/1184584
http://drupal.org/node/1184486

mhahndl’s picture

@neoglez: go wild further! :)

Bahlool’s picture

subscribe

JohnnyX’s picture

Subscribe.

Tested the dev release and get a white screen after during enabling "Views Selective Exposed Filters". So waiting for a working release and take a look at the issues here :)

neoglez’s picture

JohnnyX’s picture

I used the dev from project page which doesn't work but I don't know how I can download the dev module via git...

JohnnyX’s picture

And git clone the module doesn't work too...
This version is not compatible with Drupal 7.x and should be replaced.

JohnnyX’s picture

name = Views Auto-refresh
description = Allows auto-refreshing of Ajax-enabled views.
package = Views
dependencies[] = views
core = 6.x

Should be wrong info file for D7 module...

neoglez’s picture

Status: Fixed » Closed (fixed)

And git clone

NO, you haven't, please read git docu.
Below the commit link where you can see what yopu posted in #35 was already fixed since tree weeks!
http://drupalcode.org/project/views_hacks.git/commitdiff/cbc24bfa59bc78d...

JohnnyX’s picture

I simple want to download views_hacks and not spend time in git... I read the version control tab page and cloned 7.x.1.x. Isn't up to date. No "update" command for git found. I'll wait for a new dev | stable release at d.o and maybe use the module later...

Thanks

Summit’s picture

Bookmarking, waiting for 7 dev projectpage release.
greetings, Martijn

bmango’s picture

Subscribing - also waiting for 7 dev project page release.

I'm not 100% sure this is the right module for my situation. I have two exposed filter dropdowns, and want to make one dependent on the other. The second dropdown lists nodes that are tagged with taxonomy terms from the first dropdown. So when someone makes a selection with the first dropdown it automatically updates the second dropdown. Is this the right module for me?

neoglez’s picture

It sounds possible if you know how to play with views. See a use case here

bmango’s picture

Thanks neoglez, that is an interesting use of filters, however I'm not sure if it fits my scenario. Many thanks for the link though.

cateye’s picture

+subscribe

cateye’s picture

It didn't work for me. I took a snapshot from Git. I installed the module (Drupal 7.7 - 7.x-3.0-rc1) and enabled it. Views showed the extra option for the filter. I also configured the exposed form to filter the results for the filter.

But the front-end didn't filter anything at all. It showed the full list.

JustMagicMaria’s picture

It is close to working for me. Thank you very much, neoglez, for your work on this (and the original authors, of course). I am using 7.8 and the latest -dev of Views Hacks.

I changed my view's Exposed Form to Exposed form style: Selective Exposed Filters. In the Settings, I checked the "Limit values for the result set" checkbox for the taxonomy term reference field I was trying to limit.

I have two other exposed filters on this view that are not taxonomy terms.

When I enter the view, my select list for the taxonomy term field shows all values (even those not in the result set). When I enter a value in another filter (like "Name starts with"), then the taxonomy term filter shows only the values in the result. However, I get "An illegal choice has been detected. Please contact the site administrator."

Also, the "-Any-" choice has been removed. +1 on that feature request. I suspect that would solve this problem.

So close to working!!

neoglez’s picture

Right now i'm having a killing work time :(, soon i'll be updating in d.o.

doublejosh’s picture

... did anyone get this solved?

infojunkie’s picture

Status: Closed (fixed) » Fixed

I just committed an updated method for selective filters. It's completely different from the D6 method, and it it works well I will backport it to D6. Here's how it works:

The module now creates a new selective filter for every registered filter that it finds in the system, e.g. Node: title (selective). Select this filter instead of the original and expose it.

Please try it (12 hours from now or from git directly) and let me know how it works for you!

checker’s picture

Thanks a lot for this update. The module looks like more stable than before. I don't know if it is a bug or missing feature: If you select a filter for an entity type that is not a node you will get pdo exceptions.

infojunkie’s picture

Assigned: neoglez » Unassigned

@checker, please open a new issue describing the error that you get and attach the exported view. Ideally, the view would use nothing but core Drupal objects to allow me to reproduce the error.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

doublejosh’s picture

Status: Closed (fixed) » Needs work

Doesn't seem to work with taxonomy.

Using with taxonomy all I get in the list is "Actual values will be available at run-time"
Tried all the forms* of taxonomy term available through the UI and with/without choosing "Limit list to selected items."

  • Field: MyVocab (taxonomy_vocabulary_#) (selective)
  • Content: Has taxonomy term (selective)
  • Taxonomy term: Term (selective)
  • Taxonomy term: Name (selective)

Using in conjunction with BEF.

doublejosh’s picture

When used without BEF, the list is just empty.

infojunkie’s picture

Status: Needs work » Closed (fixed)

Please open a new issue describing the problem you're having. This issue was created to request the porting of the module to D7.

doublejosh’s picture

Dubs’s picture

For me it works on Taxonomy terms BUT all that's shown in the drop down is the terms IDs and not the text. I've worked around this with a custom modules that replaces the text with hook_form_alter but there must be a more elegant way?