Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: Gizmo in Oktober 03, 2005, 03:33:28 VORMITTAG

Titel: SSI snippet, display holidays and events with dates
Beitrag von: Gizmo in Oktober 03, 2005, 03:33:28 VORMITTAG
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>
Titel: Re: SSI snippet, display holidays and events with dates
Beitrag von: kimncris in November 09, 2005, 03:08:55 NACHMITTAGS
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
Titel: Re: SSI snippet, display holidays and events with dates
Beitrag von: kimncris in November 09, 2005, 03:14:23 NACHMITTAGS
actually- I just noticed that the displayed dates are wrong too- but I'm still trying to figure this out if anyone knows how....
Titel: Re: SSI snippet, display holidays and events with dates
Beitrag von: carhartt in Februar 05, 2006, 07:22:51 VORMITTAG
hmm... any idea?!
Titel: Re: SSI snippet, display holidays and events with dates
Beitrag von: myaicons in Februar 10, 2008, 05:56:51 NACHMITTAGS
does this work for 1.1.4 ???
Titel: Re: SSI snippet, display holidays and events with dates
Beitrag von: Oldiesmann in Februar 21, 2008, 01:33:01 VORMITTAG
Yes, it should work for 1.1.4.