So this is a pretty specific issue for my use case but I feel like implementing such a feature would make this module way more powerful than it already is (great module btw)...
My use case is more complicated than my example but basically I am trying to nest global filters like so:
Taxonomy level 1 (view based filter)
Taxonomy level 2 (view based filter, takes args from Taxonomy level 1)
Taxonomy level 3 (view based filter, takes args from Taxonomy level 2)
Results View
Each level is generated based on the state of the level before it (using global filters to filter other global filters). Ideally I would like levels 2, 3 and 'results' to reset when a new selection is made in Taxonomy level 1 and so forth. Without some kind of patch if I update level 2 and this selection eliminates my current level 3 selection from the list, that taxonomy term remains selected even though it is no longer an option.
I have tried to do this manually by calling 'global_filter_clear_filters(array('view_categories_lvl_4_taxonomy'));' from the view footer if the results set does not contain the currently selected term retrieved via (global_filter_get_session_value('view_categories_lvl_4_taxonomy');) but unfortunately that footer code is never executed by the filter view.
Thanks,
Chris
Comment | File | Size | Author |
---|---|---|---|
#4 | custom-PHP-on-filter-change-1883528-3.patch | 2.32 KB | webstudiodelta |
Comments
Comment #1
webstudiodelta CreditAttribution: webstudiodelta commentedI have modified my local copy of Global Filter to support an additional PHP field that is executed (evaled) whenever that particular filter is updated. This should add boat loads of functionality to Global Filter, allowing administrators to create chained/dependent filters and execute other custom code.
It appears to be working pretty well and I would be glad to share the additional functionality however I have never contributed a module patch before, so I will tackle this tomorrow.
Comment #2
RdeBoerThanks and look forward to the patch Chris!
When you generate the patch, please make sure to generate it against the 7.x-1.x branch, in other words the 7.x-1.x-dev snapshot release, not 7.x-1.9.
Comment #3
webstudiodelta CreditAttribution: webstudiodelta commentedI have created a very simple patch (hopefully I did this correctly):
custom-PHP-on-filter-change-1883528-3.patch
It modifies the block configuration form for individual filters to include an additional PHP filter that is evaluated whenever the value of that particular filter changes. The code is evaluated inside the 'global_filter_set_on_session' function.
I have tested it using the global_filter_clear_filters(array('another_filters_name')); The code seems to execute properly and the events chain from filter to filter as intended.
Comment #4
webstudiodelta CreditAttribution: webstudiodelta commentedI have created a very simple patch (hopefully I did this correctly):
custom-PHP-on-filter-change-1883528-3.patch
It modifies the block configuration form for individual filters to include an additional PHP filter that is evaluated whenever the value of that particular filter changes. The code is evaluated inside the 'global_filter_set_on_session' function.
I have tested it using the global_filter_clear_filters(array('another_filters_name')); The code seems to execute properly and the events chain from filter to filter as intended.
Comment #7
webstudiodelta CreditAttribution: webstudiodelta commentedComment #8
RdeBoerThanks Chris,
Looks good. Will apply when I have time.
For future reference: I don't think we use camel-case in Drupal PHP, although we do in Drupal Javascript -- I think.
Rik
Comment #9
RdeBoer@Chris, #4,
Hi Chris, the link to your patch file has ended up broken.
Can you please uploaded it again?
Rik
Comment #10
webstudiodelta CreditAttribution: webstudiodelta commentedI used this for another project and realized It was actually in the wrong place anyway, would be more useful if the php was executed AFTER the values changed so you could have access to the new vals. I will look into writing a new patch when I get some free time.
Comment #11
RdeBoerCool! Was just about to have another look at it.
Will wait for your patch.
Rik
Comment #12
shevgeny"Page not found" on "custom-PHP-on-filter-change-1883528-3.patch" :(
Comment #13
RdeBoer@shevgeny, #12
Yes that's what I said in #9 ....
Comment #14
RdeBoerAs mentioned in #9 and #12 the patch has gone missing.
If it is re-submitted I'm willing to have a look a applying it.
Rik