Hi Guys,
This looks very promising for me, but I can't seem to get it to work with two filters.
I have an event content type, with a start and end field. If an exhibition starts on Jan 1st and ends on Dec 31st, and I use one exposed filter, all seems fine. For example, if I choose, Apr 1st, I see all events on that date, including events that cross over that date, such as an exhibition that starts on Jan 1st and ends on Dec 31st.
However, if I put in two exposed filters so users can search for all events from Apr 1st to Apr 16th, I seem to be missing something.
Could you point me in the right direction please? I'll gladly write up your response as a documentation page for the Drupal.org Handbook, which you can also include then in the README.txt file for the module.
Thanks a lot.
Comments
Comment #1
phelix commentedAny luck getting this to work? I am having the same problem. When using in between on dates it does not display anything.
Comment #2
markconroy commentedNo luck yet. I've moved on to another project now, but would love to get this working. For the moment, client is happy with one filter.
Comment #3
cmonnow commentedHi,
I don't know why but for me the whole views plug-in system is strangely intimidating.
In the meantime, perhaps you can hook (or hack) into what already exists in the Date module without the use of this module at all. Setting an exposed "event start" date filter with day granularity and a preset "in between" filter would give you all the variables you need except event "end" date (easily fixed by adding a "2" to the field name) to establish a formula that meets your requirements - event start date field name, event end date field name, exposed start date variable can be used as an "earliest day" and exposed end date variable can be re-purposed as the "latest day" (rather than being the "latest start date").
It's a bit of a headache wrapping one's head around the precise formula that would work (e.g. when to use ">=" vs ">") but I believe this is the general idea:
(Event start date between exposed start (>=) AND exposed finish (<=) (where exposed start = exposed finish where 1 specific day wanted)
OR (Event end date between exposed start (>) AND exposed finish (<=))
OR (Event start date less than or equal to (<=) exposed start date AND event end date more than (>) exposed end date)
If you haven't used a MODULENAME_views_query_alter function before,
"This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. MODULENAME.views.inc must be in the directory specified by the 'path' key returned by MODULENAME_views_api(), or the same directory as the .module file, if 'path' is unspecified."
So in your
custom_example.module, you'll have this:And in your
custom_example.views.incsomething like this to hack your specific view type:Once you empty the caches hopefully it would achieve your goal.
Cheers
Comment #4
tobiberlinI had no problem to use this module in that way: added two filters of that kind and was able to get the correct result - so far... I tested just with a few items
Comment #5
tobiberlinJust to clearify... I had some issues as well but what solves it: put the two between filters into a filter group connected by "OR" (under "rearrange" on the administration part for filters on your views administration page) and connect this filter group with "AND" with all the other filters. In that way I was able to get a "from XY to Z" date filter listing all the events which appear to be valid in this time.
Comment #6
cmonnow commentedThat's good. I never even installed this module since after reading the same issue in two posts I assumed it was not supported! I should test it in the future to see how the final query formula is arranged and if it's different to my method.
Comment #7
liquidcms commentedi think my question is the same, but please tell me if it isn't.. i am trying to check for a range falling within a range.. basically the same picture as on the project page where i specify start and end and want to find any result in the 4 options shown (note: this isnt really the use that project maintainer intended for that picture).
the real world use of this is simple:
- i have a list of events with start/end dates
- i want to filter by semester
- semester does not have to fall cleanly on event dates: see picture from home page where semester start/end are the start/end dates shown.
if i add 2 of the view between filters with an OR function:
- type = Event
AND
- date between (semester start)
OR
- date between (semester end)
and i set these to match my semester, then it works for 3 of the 4 cases; but does not work for the 4th case where the event is completely contained within the semester.
Comment #8
liquidcms commentedmaybe my issue is different than original poster's; but for my case as explained above, solution is:
between dates (term start)
OR
between dates (term end)
OR
start >= (term start)
and
end <= (term end)
which looks like this: http://screencast.com/t/B3C2pzqMW
and displays as: http://screencast.com/t/riWOvyTuo7
this covers the Views config part; but for my solution code is required to:
- hide all 4 filters
- replace with a single Term selector
- on submit look up start/end dates that go with Term selected and insert into the 4 filters i have hidden.
Comment #9
3man commentedAs Tobiberlin already mentioned it works when you set the 2 between dates in OR group but when the "event” has the same start date and end date it does not work correctly. In my case some events are only one day.
Is it possible to show also the 1day events that are between the “between dates filter”
Comment #10
lubwn commentedAs liquidcms mentioned in #8, this worked for me. Little tinkering with JS and hiding some fields with CSS and it works like a charm! Thanks a lot.
It would be handy if the module did it by default but well.. I guess it is too late to ask for it anyway, since D7 is ending its life soon.