Commit c8264dec authored by Kevin Paxman's avatar Kevin Paxman
Browse files

Reverse sort order of events on home page block; limit to 3; remove unused legacy query

parent 2d4eea54
......@@ -320,21 +320,6 @@ function uw_ct_event_block_view($delta = '') {
switch ($delta) {
case 'front_page':
// Use timestampadd to correct for time zone (NOTE: having to do this MAY be a bug)
// if timezone offset is 0, then use -18000 which is correct for Waterloo, and hope we don't have anyone set to Greenwich Mean Time
// Dates now (WCMS 1.10+ w/Date 7.x-2.9-beta2+2-dev-uw_wcms1) seem to be stored in local time format, so we removed offset correction from the SQL statement below
$result = db_query("
SELECT node.nid, node.title, node.sticky,
DATE(field_data_field_event_date.field_event_date_value) AS date_start,
DATE(field_data_field_event_date.field_event_date_value2) AS date_end
FROM {node} node LEFT JOIN {field_data_field_event_date} field_data_field_event_date ON node.nid = field_data_field_event_date.entity_id
WHERE node.type = 'uw_event' AND node.status = 1 AND node.promote = 1
-- Show any event that *ends* in the future.
HAVING date_end >= CURRENT_DATE
ORDER BY node.sticky DESC, date_start ASC, date_end ASC
LIMIT 3
");
$events = db_select('node', 'n');
$events->leftJoin('field_data_field_event_date', 'events', 'events.entity_id = n.nid');
$events->fields('events', array('field_event_date_value', 'field_event_date_value2'));
......@@ -343,8 +328,9 @@ function uw_ct_event_block_view($delta = '') {
$events->condition('n.status' , 1, '=');
$events->condition('n.promote', 1, '=');
$events->orderBy('n.sticky');
$events->orderBy('events.field_event_date_value', 'DESC');
$events->orderBy('events.field_event_date_value', 'ASC');
$events->orderBy('n.title');
$events->range(0, 3);
$result = $events->execute();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment