Advertisement:

Author Topic: SSI snippet, display holidays and events with dates  (Read 20163 times)

Offline Gizmo

  • Newbie
  • *
  • Posts: 2
SSI snippet, display holidays and events with dates
« 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 hxxp:www.cmsmadesimple.org [nonactive], which appears on the frontpage of my CMSMS site. Thought someone might

Code: [Select]
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..

Code: [Select]
<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>

Offline kimncris

  • Semi-Newbie
  • *
  • Posts: 61
Re: SSI snippet, display holidays and events with dates
« Reply #1 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

Offline kimncris

  • Semi-Newbie
  • *
  • Posts: 61
Re: SSI snippet, display holidays and events with dates
« Reply #2 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....

Offline carhartt

  • Semi-Newbie
  • *
  • Posts: 73
  • Gender: Male
  • I'm a lamer!
Re: SSI snippet, display holidays and events with dates
« Reply #3 on: February 05, 2006, 07:22:51 AM »
hmm... any idea?!
straight is great! ;)

Offline myaicons

  • Jr. Member
  • **
  • Posts: 228
  • Gender: Female
Re: SSI snippet, display holidays and events with dates
« Reply #4 on: February 10, 2008, 05:56:51 PM »
does this work for 1.1.4 ???
i scratch your back you scratch my back...
funny thing about my back is its located on my...

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: SSI snippet, display holidays and events with dates
« Reply #5 on: February 21, 2008, 01:33:01 AM »
Yes, it should work for 1.1.4.
Michael Eshom
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org