Trying to figure out how I can get one widget to populate the contextual filter for two different views, where each view's contextual filter is on a different field.

So for example, if view A has a field called diameter and view B has a field called radius, I want the user to be able to enter a value in only one single text box and have it set the contextual filter for both views.

Currently this does not seem to be possible using Views Global Filters or any other contrib module I can find.

Seems like the only limitation would be that the data type for all the fields would have to be the same.

Thanks

Comments

davehochh created an issue.

RdeBoer’s picture

Whoa! That is a very niche requirement, Dave!
No you cannot do this with the module as it stands.
How good are you at PHP?
Rik

hochh1707’s picture

I'm not bad at PHP. I found a workaround, but it still seems like this might be worth building. You can combine filters for page Views, but it might be worth having combined filters multiple block Views.

RdeBoer’s picture

@davehochh

.... So.... Patch for the community's consideration?

Rik

hochh1707’s picture

Willing and eager to contribute. Just a little new to the process. I am reading up on it now and come back with ideas and or questions in the next day or two. Thanks.

hochh1707’s picture

Haven't forgotten about this but I'm studying the Global Filters code (in my spare time) to see if I can figure out how to implement what I want. Definitely a new challenge for me.

hochh1707’s picture

I was looking through the Global Filters code today. Some thoughts about how to implement this feature.

1. The $filters variable contains the field names and filter values. Looks like this variable is set on line 207 of global_filter.storage.inc. I assume all the values from this variable are passed to any views with Global Filters (not sure how that happens, I don't think it is very important for my purposes).

2. How to tell the module to populate $filters with more than one field name, but the same value? It seems like the best way would be to have a "combined filter" check box when the user is setting up their Global Filter block. When the box is checked, the module will build the $filters variable so that the only widget that gets displayed is the widget for the first field, and every field will be added to $filters, but they will all be assigned the same value as the first field.

Not yet sure exactly how to code this. I'm going to work on it some more later. Any thoughts / comments are appreciated.

Thanks.