$start, 'end' => $end); } /** * Grab an array of event teasers that fit a time span * * @param $start * Start date in ISO format * @param $end * End date in ISO format * @param $type * 'all' -- return all event types * 'events' -- return only events * 'exhibits' -- return only exhibits * * @return * An array of events, exhibits starting in the time span and exhibits ending * after the begining of the time span. */ function get_events($start, $end, $type = 'all'){ if($type == 'all' || $type == 'events'){ // Grab all events starting, ending or occurring within the time span // Events are TID 1 $sqlEvents = "SELECT n.nid, t.tid AS tid FROM {node} n LEFT JOIN {content_type_featured_event} e ON n.vid = e.vid LEFT JOIN {term_node} t ON n.nid = t.nid WHERE n.status = 1 AND e.field_date_value < '$end' AND e.field_date_end_value > '$start' AND t.tid = 1 ORDER BY e.field_date_value ASC, n.nid ASC"; $resultEvents = db_query(db_rewrite_sql($sqlEvents)); while($events = db_fetch_object($resultEvents)) { $event = node_load($events->nid); $eventList .= node_view($event, $teaser = TRUE); } } if($type == 'all' || $type == 'exhibits'){ // Grab all exhibits starting within the time frame // Exhibitions are TID 2 $sqlExhibits = "SELECT n.nid, t.tid AS tid FROM {node} n LEFT JOIN {content_type_featured_event} e ON n.vid = e.vid LEFT JOIN {term_node} t ON n.nid = t.nid WHERE n.status = 1 AND e.field_date_value < '$end' AND e.field_date_end_value > '$start' AND e.field_date_value > '$start' AND t.tid = 2 ORDER BY e.field_date_value ASC, n.nid ASC"; $resultExhibits = db_query(db_rewrite_sql($sqlExhibits)); while($exhibits = db_fetch_object($resultExhibits)) { $exhibit = node_load($exhibits->nid); $exhibitListStarting .= node_view($exhibit, $teaser = TRUE); } // Grab all exhibits ending or occurring within the time frame $sqlExhibitsEnding = "SELECT n.nid, e.field_date_value, e.field_date_end_value FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid LEFT JOIN {content_type_featured_event} e ON n.vid = e.vid LEFT JOIN {term_node} t ON n.nid = t.nid WHERE n.status = 1 AND e.field_date_value < '$start' AND e.field_date_value < '$end' AND e.field_date_end_value > '$start' AND t.tid = 2 ORDER BY e.field_date_end_value ASC, n.nid ASC"; $resultExhibitsEnding = db_query(db_rewrite_sql($sqlExhibitsEnding)); while($exhibitsEnding = db_fetch_object($resultExhibitsEnding)) { $exhibitEnding = node_load($exhibitsEnding->nid); $exhibitListEnding .= node_view($exhibitEnding, $teaser = TRUE); } } return array( 'events' => $eventList, 'exhibitsStarting' => $exhibitListStarting, 'exhibitsEnding' => $exhibitListEnding, ); }