Include Events?

eliza411 - April 29, 2007 - 17:02
Project:Views Date Range Filter
Version:4.7.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

Is it possible/difficult to include the start and end times for Events in this?

#1

douggreen - April 29, 2007 - 23:24
Status:active» duplicate

See #133317

#2

eliza411 - May 6, 2007 - 14:08

I apologize for the duplication, and I appreciate you marking this as such, as it forced me to look down others paths.

I was able to attain the functionality of the Date Range Filters by using the Argument Handling Code, which isn't as elegant, but it does allow me to build a date range on an established 4.7/Event Calendar site. Based on the example provided by quicksketch at http://drupal.org/node/70145#comment-204051, I created a filter that does not actually use arguments provided in the URL, but does filter whether a certain event falls inside the academic year.

By defining range in the first two variables, specifying the field name in 'field', formatting that field to match the output of the mktime command in the 'value', and choosing an operator, I have a custom date range filter.
The very last line is included per quicksketch's advice in the comment I was modeling this from. His post also shows how to incorporate arguments from the URL.

// second, minute, hour, month, day, year
$year_begin  = mktime(0, 0, 0, 7, 1 , date("Y")-1);
$year_end  = mktime(0, 0, 0, 10, 1 , date("Y"));

$view->filter[] = array(
    'vid' => $view->vid,
    'tablename' => '',
    'field' => 'event.event_start',
    'value' => strftime('%Y-%m-%d',$year_begin),
    'operator' => '>',
    'options' => '',
    'position' => count($view->filter),
    'id' => event.event_start,
  );
$view->filter[] = array(
    'vid' => $view->vid,
    'tablename' => '',
    'field' => 'event.event_start',
    'value' => strftime('%Y-%m-%d',$year_end),
    'operator' => '<',
    'options' => '',
    'position' => count($view->filter),
    'id' => event.event_start,
  );

$view->query = '';

 
 

Drupal is a registered trademark of Dries Buytaert.