Hello,
I am trying to do something which seems like it should be a (relatively) common need, but not finding any documentation.
I will try to describe it as simply as possible.
I have a view.
It has 3 exposed filters: Radius, Zip Code, and Taxonomy Term.
Users must submit a zip code, Radius has a default if they do not fill it out, and Taxonomy Term is optional.
However, I'd like some results to be shown even if they are outside of the radius area--essentially, think of this as a local vendor directory with a few e-commerce listings that are relevant regardless of where you are located.
I'm also going to put a "Don't show national listings" exposed filter in, which will be just the label for a toggle that chooses to show national listings or not (exposed and relabeled: CCK Field "National" essentially).
Does anyone have any thoughts? The important things to keep in mind are:
- I can't use an attachment because the results must be filtered into the main results--they can not show up in their own block (however, if that is the only option, I will consider it)
- This is a very small need. We have a few thousand vendors in a niche industry in a few countries, and we have about 6-10 per country who would use this, all in different categories of that niche industry (i.e. accessories for 2, photography for 4, event planning for 3--but in most areas, you'll have about a dozen non-national results for these categories)
- I am loathe to upgrade to Views 3 because this is a site with a fair amount of traffic & a large number of modules & dependencies. If I can avoid upgrading while Views 3 is in production, I'll feel a lot better about the universe.
- I have found a few "more complex" views modules, but before I invest a lot of time experimenting with those, I want to make sure that this is actually possible
- I know that you can do this relatively easy with a straight-up database query, and have already come up with a few possibilities for writing that out. However, I would like to keep this in views, for all the standard reasons that someone wants to keep a big part of their programming in a standardized format which is consistent with the rest of their project.
Thanks greatly--and please feel free to speculate or theorize about different approaches.
Comments
you might like to look at
you might like to look at hook_views_alter_query() to manipulate the actual condition of the query.
--
Rachel J.
Thanks Rachel. Esmerel has
Thanks Rachel. Esmerel has also suggested using Views_OR via the IRC room, so I'm giving that a shot first--it just puts the OR functionality into a GUI.
I provide free Drupal support on Thursdays: booking calendar coming soon.
Views_Or did not work, so I'm
Views_Or did not work, so I'm going to look into customizing the query... hopefully this is something I can do.
Thanks for the suggestion.
I provide free Drupal support on Thursdays: booking calendar coming soon.
Rachel, do you mean
Rachel, do you mean hook_view_query_alter()? I can't find much when I google search for hook_views_alter_query().... thanks in advance!
I provide free Drupal support on Thursdays: booking calendar coming soon.
Solved!
OK, so the views_or module (which isn't really accessible via search unless you use the escape character--just go to http://drupal.org/project/views_or) does this beautifully.
Just make sure you set the right order of filters: In my case, I had to put in "Views Or Begin", then the condition for type of node, then Views Or Next, then the proximity filter, and finally "Views Or End".
Works like a charm.
Thanks for all of the help, especially Merlin of Chaos via Esmerel in the IRC!
I provide free Drupal support on Thursdays: booking calendar coming soon.