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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webstudiodelta’s picture

I 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.

RdeBoer’s picture

Version: 7.x-1.9 » 7.x-1.x-dev

Thanks 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.

webstudiodelta’s picture

Status: Active » Needs review

I 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.

webstudiodelta’s picture

I 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.

webstudiodelta’s picture

Issue tags: +php filter, +Custom PHP, +global filter
RdeBoer’s picture

Assigned: Unassigned » RdeBoer

Thanks 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

RdeBoer’s picture

Title: Reset specific filter when another filter is changed/PHP to execute when a filter is updated... » PHP to execute when a filter is updated...

@Chris, #4,
Hi Chris, the link to your patch file has ended up broken.
Can you please uploaded it again?
Rik

webstudiodelta’s picture

I 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.

RdeBoer’s picture

Cool! Was just about to have another look at it.
Will wait for your patch.
Rik

shevgeny’s picture

"Page not found" on "custom-PHP-on-filter-change-1883528-3.patch" :(

RdeBoer’s picture

@shevgeny, #12
Yes that's what I said in #9 ....

RdeBoer’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

As 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