Filtering dates for a 'period of time' view

Events happening in the community are now at Drupal community events on www.drupal.org.
hip's picture

Hi,
I'm using views.module (altogether with some other modules) to run an events site for my town. I'm trying to get some views from the events nodes (CCK content type) but I don't have a clue how to filter them properly. The views I need are:
- events today (it doesn't matter if before or after 'now', see it doesn't seem to be an option to me)
- events tomorrow
- events after tomorrow
- events for all three
- all future events

The date field is mandatory but a 'to date' date is optional, for there are events such as a film shot (one only date) or a painting exhibition (from-to date). For the 'all 3 days' view I was guessing a solution similar to:
(view filter)
- start date (mandatory) : 'less than or equal to' today + 3
- end date (optional): 'greater than' today-1

where 'today' is not 'now' but the whole day for the given zone time.

So, I believe there may be an easy solution I'm missing, because I think it's not a complex scenario but maybe...
Could you please give me a hand or, at least let me know where should I start learning from or re-posting this story?

I've just joined this group and I hope it's the right place to post my previous doubt. (if not you may kick me off :-) )

Thanx in advance,
hip

Comments

suggestions

fmitchell's picture

if you want to just see what is today, in views, set the filter to your date cck type and option should be 'now'. the list of dates to choose from should be able to be limited to year, month, or day equal to 'now'.

for your other views, build a similar view, but have an argument pass in equal to a date. then have the filter use the date.

for future dates, you may need a custom module. i just built one that utilized the DateTime object in PHP. you can use the modify() function to go back and forth between days and then display the links from that module. check the PHP documentation.

something similar to:

<?php
//get the current view that accepts arguments
$view = views_get_view('view_name');

/<
strong>
*
manipulate the $views object here and get parameters from array
*
</
strong>/

//get today and move ahead one day
$today = getdate(mktime());
$day = new DateTime($today['mday'] . '-' . $today['month'] . '-' . $today['year']); //DateTime is kind of fickle
$day->modify("+1 day");
$tomorrow = $day->format("d");

$link_to_events_tomorrow = l('foo', "views_url" . $tomorrow);
return
theme('item_list', $link_to_events_tomorrow);
?>

something similar to that.

Event Management Systems

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: