Hi
I installed the events component and I use the "by Year" Mode to display my events. But I only want to display upcoming events there. I tried several things, but nothing worked. This is the code which prints out the events, I hope someone has a suggestion to realise this.
PHP Code:
function showEventsByYear ($year,$limit,$limitstart) {
global $database, $option, $Itemid, $gid, $mosConfig_list_limit;
$sql = "SELECT * FROM #__categories as b, #__events WHERE AND #__events.catid = b.id AND b.access <= $gid AND #__events.access <= $gid AND publish_up LIKE '$year%' AND (publish_down >= '$year%' OR publish_down = '0000-00-00 00:00:00') AND #__events.state = '1'";
$database->setQuery($sql);
$counter = $database->loadObjectList();
$total = count( $counter );
// MLr: discuss replacing _CAL_CONF_EVENT_LIST_ROWS_PPG with $mosConfig_list_limit
$limit = $limit ? $limit : _CAL_CONF_EVENT_LIST_ROWS_PPG;
if ( $total <= $limit ) {
$limitstart = 0;
}
$rows = listEventsByYear ($year,$limitstart,$limit);
$num_events = count($rows);
$chdate = "";
echo "<fieldset><legend class='ev_fieldset'>"._CAL_LANG_ARCHIVE."</legend><br />\n";
echo "<table align='center' width='90%' cellspacing='0' cellpadding='5' class='ev_table'>\n";
if ($num_events>0){
for ($r = 0; $r < count($rows); $r++) {
$row = $rows[$r];
$event_up = new mosEventDate( $row->publish_up );
$event_up->day = sprintf( "%02d", $event_up->day);
$event_up->month = sprintf( "%02d", $event_up->month);
$event_up->year = sprintf( "%4d", $event_up->year);
$event_month_year = $event_up->month . $event_up->year;
$contactlink = mosEventsHTML::getUserMailtoLink($row->id, $row->created_by);
$catid = $row->catid;
$catname = mosEventsHTML::getCategoryName($row->catid);
if (($event_month_year <> $chdate) && $chdate<>""){
echo "</td>\n";
}
if ($event_month_year <> $chdate){
echo "<tr><td width='50' class='ev_td_left'>".mosEventsHTML::getDateFormat($event_up->year,$event_up->month,'',3)."</td>\n";
echo "<td class='ev_td_right'><ul class='ev_ul'>\n ";
}
HTML_events::viewEventRow ($row->id,$row->title,'view_detail',$event_up->year,$event_up->month,$event_up->day,$contactlink, $option, $Itemid);
echo " :: ";
HTML_events::viewEventDate ($row->id,$row->title,'view_detail',$event_up->year,$event_up->month,$event_up->day,$contactlink, $option, $Itemid);
$chdate = $event_month_year;
if ($event_month_year <> $chdate){
echo "</ul>\n ";
}
}
} else {
echo "<tr>";
echo "<td align='left' valign='top' class='ev_td_right'>\n";
echo _CAL_LANG_NO_EVENTFOR." <b>".$year."</b></td>";
}
echo "</tr></table><br />\n";
echo "</fieldset><br />\n";
showNavTableText($year, $total, $limitstart, $limit, 'view_year');
}