Cheers all,
I've got a view set up to pull all events that are between "now" and 12:00AM of the following day. I exposed the date filter to allow visitors to search for events on another day, but I've got two problems with that:
1) The exposed filter is displaying a time option when I really just want a month/date/year.
2) The filter includes a "To" option when what I want is to only have a single day and have the view automatically include 12:00AM of the following day as the "To" option.
The before and after screenshots are what I've got now and what I'm trying to achieve.
I assume I'm looking at some sort of tpl.php theming but I really have no idea which files to work with to do what I'm after.
Thanks for any help!
Comments
Well, I'm getting closer.
Well, I'm getting closer. Using a custom module which calls hook_form_alter I did the following:
unsetting the max array removes it from the form and I rearranged the order of date fields with the next line, #date_format. The problem that I'm running into is that because max is unset it's not properly filtering the results so I get a long string of the same event. I'm assuming I'll need to figure out how to put "11:59pm" as the end time of whatever date the visitor selects with the exposed filter.
This isn't that hard,
This isn't that hard, actually!
I may have misunderstood your problem, so let me re-state it and then offer a few suggestions.
My understanding is that you want to show all events that occur between the current time and tomorrow at 12 AM.
Can you not simply have two filters, one for Date with time set which is NOT exposed, and another filter with date with the granularity set to month/year? (That way they can only determine the month/year and will not see the time option at all). I tested that and it appears that it would work, but I may be misunderstanding some of the goals you have.
If that isn't possible, or I've misunderstood, then I would suggest that you theme the view to hide the filter.
Basically, create a custom tpl.php for that view. You can figure out the name by clicking Theme: Information on the left-hand side of the view editor for the specific view you want to theme. You will see a bunch of file names. The last file name in the first set of file names is the one you want to edit.
On one of my sites, I have a view with a lot of exposed filters. However, the exposed filters are ugly and clunky looking, so I don't want my users to see the way that they look. What I did was copy the default views template, rename it to the last filename in the first set of filenames under Theme:Information, then upload it, then go to my view and click "Rescan" on that theme section. Voila: The last filename gets bolded, and is the one applied.
Here is the code I used for my custom tpl.php:
What makes it not display the actual exposed filters is that I put the word "OLD" in the "If ($exposed)" line. You could delete the section entirely. I just did not.
Keep in mind, once you have done that, you need to give your visitor someway to define the filters you DO want them to define. I did that by creating a custom search form, with the form inputs being copied from the drupal exposed default form.
Not that hard--play with it and let me know if you have further questions.
I provide free Drupal support on Thursdays: booking calendar coming soon.
Thanks for looking into this
Thanks for looking into this -- I initially attempted something along the lines of what you're describing but it didn't seem to work in my case, though it's entirely possible that I simply screwed it up. I tried again and ended up with the following results:
11:00am - Event #1
3:30pm - Event #2
11:00am - Event #1
It's currently 2:15pm my time, so the only thing that should appear is 3:30pm Event #2.
Here's what I'm trying to do since I wasn't all that clear in my initial post: I've got a "daily events" view/block with a filter that defaults to showing everything happening between now and 12:00am tomorrow. That all works fine. My problem arises when I try to expose the date filter. I'd like the user to be able to select a single date in the future and have the view display all events from 12:01am on the date they select through 12:00am the following date.
By default, the form creates both the from and the to select boxes when I only want it to create a single date select (from/min) and have Drupal calculate the to/max based on the value of the exposed date select. Unsetting the max using a custom module and hook_form_alter solves the problem of hiding the second series of form fields but now my problem is that it's effectively ignoring the max and showing me all records that are greater than or equal to the min. I assume I need something along the lines of "if there is a querystring, get the value, figure out the next date, and set the max to that at 12:00am" but I have no idea how to do that.
After working on this a bit
After working on this a bit more, I've discovered that my filter isn't working at all. My custom module does a good job of rewriting the form, but even the default version of the filter doesn't work. I've tried "equal to" and "is between" and neither seems to work properly. When I submit the form, everything displays -- including events that are not scheduled for the day that I select. It's as if actually using the exposed filter turns off the filter completely.