well- I've been struggling with this one, trying to modify my ssi.php (I know- bad idea) to display dates alongside my event list
and I think I've finally done it
heres the code- I made my own new SSI function called dbevents
I'm sure there was a little more elegant way to do this- especially when it comes to displaying the date in "Day of week - MM/DD/YY" format, but I don't know php at all and this was the only way I could figure out how to do it.
It seems to be working, though- you can check the results here: http://www.scgarrison.net/index.php
and here's my code. the major changes from ssi_recentEvents are in red. Please let me know if you see anything funky...
Lainaa/***************************db events query**********************************/
// Show the upcoming events with dates in ASCENDING order even to guests.
function ssi_dbEvents($max_events = 7, $output_method = 'echo')
{
global $context,$db_prefix, $user_info, $scripturl, $modSettings, $txt, $sc;
// Find all events which are happening in the near future that the member can see.
$request = db_query("
SELECT
cal.ID_EVENT, DAYOFMONTH(cal.eventDate) AS day, cal.eventDate, year(cal.eventDate) AS year, MONTH(cal.eventDate) AS month, DAYOFWEEK(cal.eventDate) AS weekday, cal.title, cal.ID_MEMBER, cal.ID_TOPIC,
cal.ID_BOARD, t.ID_FIRST_MSG
FROM {$db_prefix}calendar AS cal, {$db_prefix}boards AS b, {$db_prefix}topics AS t
WHERE cal.eventDate >= '" . strftime('%Y-%m-%d', forum_time(false)) . "'
AND cal.ID_TOPIC = t.ID_TOPIC
AND cal.ID_BOARD = b.ID_BOARD
/*AND $user_info[query_see_board]*/
ORDER BY cal.eventDate ASC
LIMIT $max_events", __FILE__, __LINE__);
$return = array();
$duplicates = array();
while ($row = mysql_fetch_assoc($request))
{
//replace day #s with words instead
if ($row['weekday'] == "1") {$dayword=Sunday;}
elseif ($row['weekday'] == "2") {$dayword=Monday;}
elseif ($row['weekday'] == "3") {$dayword=Tuesday;}
elseif ($row['weekday'] == "4") {$dayword=Wednesday;}
elseif ($row['weekday'] == "5") {$dayword=Thursday;}
elseif ($row['weekday'] == "6") {$dayword=Friday;}
else {$dayword=Saturday;}
//if 2010 or higher chop off the 2000 so the year displays as the last 2 digits otherwise contruct the year as a 0 and the lastdigit
if ($row['year'] > 2009) $shortyear = (($row['year'])-2000);
else $shortyear="0";
if ($row['year'] < 2010) $lastdigit = (($row['year'])-2000);
// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
if (!empty($duplicates[$row['title'] . $row['ID_TOPIC']]))
continue;
// Censor the title.
censorText($row['title']);
$return[$row['day']][] = array(
'id' => $row['ID_EVENT'],
'title' => $row['title'],
'day' =>$row['day'],
'weekday' =>$dayword,
'month' =>$row['month'],
'year' =>$shortyear,
'lastdigit' =>$lastdigit,
/*'can_edit' => allowedTo('calendar_edit_any') || ($row['ID_MEMBER'] == $ID_MEMBER && allowedTo('calendar_edit_own')),*/
'modify_href' => $scripturl . '?action=post;msg=' . $row['ID_FIRST_MSG'] . ';topic=' . $row['ID_TOPIC'] . '.0;calendar;eventid=' . $row['ID_EVENT'] . ';sesc=' . $sc,
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['title'] . '</a>',
'is_last' => false
);
// Let's not show this one again, huh?
$duplicates[$row['title'] . $row['ID_TOPIC']] = true;
}
mysql_free_result($request);
foreach ($return as $mday => $array)
$return[$mday][count($array) - 1]['is_last'] = true;
if ($output_method != 'echo' || empty($return))
return $return;
// Well the output method is echo.
/* echo '
<span style="color: #' . $modSettings['cal_eventcolor'] . ';">' . $txt['calendar4'] . '</span> ';*/
foreach ($return as $mday => $array)
foreach ($array as $event)
{
//only display the items as links if not a guest.
if ($context['user']['is_guest'])
{
echo '<br>
' .$event['weekday'],' '. $event['month'],'/'. $event['day'],'/'. $event['year'], $event['lastdigit'],'<br>'. $event['title']. '<br><br></a>' . (!$event['is_last'] ? ', ' : '');
}
else
{
echo '
<a href="' . $event['href'] . '">' . $event['weekday'],' '. $event['month'],'/'. $event['day'],'/'. $event['year'], $event['lastdigit'],'<br>'. $event['title']. '<br><br></a>' . (!$event['is_last'] ? ', ' : '');
}
}
}
/***********************************************************************************/