/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function cmp_date($a,$b) { if ($a['start_date'] > $b['start_date']) return 1; if ($a['start_date'] < $b['start_date']) return -1; return 0; } if (module_exists('civicrm')) { civicrm_initialize(TRUE); require_once 'api/v2/Event.php'; $params = array (); $myEvents = civicrm_event_search( $params ); if ($myEvents) { $count = 0; $last = ''; usort($myEvents,'cmp_date'); foreach ($myEvents as $event) { $now = date('Y-m-d H:i:s'); if ($now > $event['start_date']) continue; $startdate = date('D M j Y',strtotime($event['start_date'])); $enddate = date('D M j Y',strtotime($event['end_date'])); $eventid = $event['id']; list($title_place, $title_desc) = split(":",$event['title'],2); if ($last != $startdate) { } $display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'<br />'; echo $display; $count++; $last = $startdate; if ($count > 8) break; // this limits the number of events to 8 - put in whatever number suits you } if ($count > 0) { } else { echo 'No events found.'; } } else { echo 'No events found.'; } } ?>