Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Gizmo on October 03, 2005, 03:33:28 AM

Title: SSI snippet, display holidays and events with dates
Post by: Gizmo on October 03, 2005, 03:33:28 AM
For some reason I can't post to the tips & tricks board, so here it goes instead.

SSI-type snippet to show events and "Holidays" (which I use as important dates) for use on a frontpage or the like. Get rid of the first two lines and you can use it in your template instead if you don't like how SMF displays the upcoming calendar. The main advantage of it is that it displays holidays with dates.

I use this code as a "custom tag" for CMSMS (http://www.cmsmadesimple.org), which appears on the frontpage of my CMSMS site. Thought someone might


require("./smf/SSI.php");

global $modSettings, $scripturl;


if (isset($modSettings['cal_today_event'])) {

echo "<div class=\"calendareventsarea\">";
echo "<div class=\"calendarheader\">Upcoming Events:</div>\n";


$events = unserialize($modSettings['cal_today_event']);

foreach ($events as $date=>$events_day_array) {
foreach ($events_day_array as $event) {
if ($event['topic'] > 0) {
echo '<div class="calendareventtitle"><a href="' . $scripturl . '?topic=' . $event['topic'] . '.0' . '">' . $event['title'] . "</a><br>\n";
}
else {
echo '<div class="calendareventtitle">' . $event['title'] . "<br>\n";
}

echo '<span class="calendardate">' . date("l M jS", strtotime($date)) . "</span></div>\n";
}
}

echo "</div>\n";
}
else {
echo "<div class=\"calendarheader\">Upcoming Events:</div>\n";
echo "<div class=\"calendarempty\">No events</div>\n";
}


if (isset($modSettings['cal_today_holiday'])) {

echo "<div class=\"calendardatearea\">";
echo "<div class=\"calendarheader\">Important Dates:</div>\n";

$holidays = unserialize($modSettings['cal_today_holiday']);

foreach ($holidays as $date=>$holiday_day_array) {

foreach ($holiday_day_array as $holiday) {
echo '<div class="calendardatetitle">';
echo '<span class="calendardate">' . date("D M jS", strtotime($date)) . ": </span>\n";
echo $holiday;
echo "</div>\n";
}
}

echo "</div>\n";
}
else {
echo "<div class=\"calendarheader\">Important Dates:</div>\n";
echo "<div class=\"calendarempty\">No Dates</div>\n";
}


Here's a stylesheet to use to get you started..


<style>
.calendardate {
color: #808080;
font-size: x-small;
font-weight: normal;
}

.calendarheader {
padding: 4px;
font-size: small;
font-weight: bold;
background-color: #336699;
color: white;
}

.calendardatetitle {
font-size: small;
font-weight: normal;
}

.calendareventtitle {
padding-top: 10px;
padding-bottom: 10px;
font-size: large;
font-weight: bold;

}

.calendarempty {
margin-left: 20px;
color: #808080;
font-size: small;
}

.calendareventsarea {
border: 5px solid #339966;
padding: 5px;
margin-bottom: 5px;
}

.calendardatearea {
padding: 5px;
}
</style>
Title: Re: SSI snippet, display holidays and events with dates
Post by: kimncris on November 09, 2005, 03:08:55 PM
this is almost exactly what I have been looking for, but it is not displaying my events as they are too far away in the future.

Does anyone know if there is a way to call ALL (x number of ) upcoming events regardless of date like the ssi_recentEvents command and still have it display the date like this?

-cris
Title: Re: SSI snippet, display holidays and events with dates
Post by: kimncris on November 09, 2005, 03:14:23 PM
actually- I just noticed that the displayed dates are wrong too- but I'm still trying to figure this out if anyone knows how....
Title: Re: SSI snippet, display holidays and events with dates
Post by: carhartt on February 05, 2006, 07:22:51 AM
hmm... any idea?!
Title: Re: SSI snippet, display holidays and events with dates
Post by: myaicons on February 10, 2008, 05:56:51 PM
does this work for 1.1.4 ???
Title: Re: SSI snippet, display holidays and events with dates
Post by: Oldiesmann on February 21, 2008, 01:33:01 AM
Yes, it should work for 1.1.4.