Monthly Archives: May 2011

Drupal Views, Calendar, extra arguments and show only upcoming events

If you have an event content type, and it has a date repeat cck field and want to use the calendar module to show only upcoming events based on that date repeat cck field, you’re going to have a tough time. At least, I did anyway. In the end I just ended up doing it through my theme template_preprocess_calendar_datebox function. It goes like this:

function template_preprocess_calendar_datebox(&$vars) {
$date = $vars['date'];
$vars['day'] = intval(substr($date, 8, 2));
if (date('d') > $vars['day']) {
$vars['link'] = $vars['day'];
// ... some other stuff

Additionally, adding extra arguments to the calendar block (in addition to the default date argument with the month granularity which you have to have) is problematic. I got to a stage where views was producing the correct SQL which gave me the results i wanted when I ran it through SQLyog, but the view itself wasn’t using the arguments. Really weird. In the end I deleted the view and rebuilt it from scratch and that seemed to fix it, I don’t know what I changed though.