TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 728
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 400
  • Total: 400

SMF Calendar Block

Started by Lesmond, September 03, 2005, 11:30:42 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

URPG

What Browser do you use to check it?

Xarcell

Works in both IE and FF. They look indentical too...

URPG

#152
That is realy strange... looks "free of events" with my "no-highlight + Monday" version as well as your last code simply copy + paste... and there are events on the calender, including a birthday...

*me feels himself going insane*  :uglystupid2:

Will try one of the other versions...

It's getting stranger an stranger... I treid True Knights Version from Reply #124 and it does somehow display events, but it does display a july event in june and none of the june events... 1st to 3rd July displayed as an event "today" when it's clearly 25th of June.

Do those blocks display past events of the month? or upcoming events within the next 30 days or...? and even in TK's version, all days got a hyperlink, all but "today"


URPG

also working, but displays a next month event "today"...

I did create an artifical event on the 25th (today) named "Test A" and it is displayed today, but still the block is displaying an July 1st to July 3rd event as today (on the 25th, was displaying it on the 24th of June too). Is there something wrong with the handling of multple day events?

RoarinRow

Quote from: URPG on June 25, 2006, 10:56:00 AM
also working, but displays a next month event "today"...

I did create an artifical event on the 25th (today) named "Test A" and it is displayed today, but still the block is displaying an July 1st to July 3rd event as today (on the 25th, was displaying it on the 24th of June too). Is there something wrong with the handling of multple day events?

In the Admin Center, check the Calendar setting - Max days in advance on board index.  What is yours set at?  Mine is set at 7 so it will always show me activities a week in advance.  Maybe that's why you're seeing July events today if yours is set to a higher number.

SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0

Lalato

How about a version that just shows upcoming events without the actually calendar...


--sam

Assistance

Quote from: True Knight on June 13, 2006, 04:16:29 AM
I finally came up with a solution!  ;D


I use this one
but i changed $day_name_length = 3;
to 1 :up:
its shweet

londonhogfan

If you go into the code and make the <table width="100%"

it will go all the way from side to side.  One of the SSI codes eventsToday isnt usually long enough to make it go 100%.  I think thats what  is causing all the problems.

I combined a couple and and removed the "post" part of the links from the calendar dates so it wouldnt take everyone to a login screen (because I don't allow most people to post calendar events).  I like the results.  Here is what I'm using.


global $scripturl, $modSettings, $sourcedir;

$now = mktime() + $modSettings['time_offset'] * 3600;
         $today = date('j',$now);
         $year = date("Y",$now);
         $month = date("n",$now);
         $days = array($today=>array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; border: solid 1px black; background-color: white; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));

         $day_name_length = 2;
         $month_href = $scripturl . '?action=calendar';
         $first_day = 0;
         $pn = array();

$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()

$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name

list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title   = htmlentities(ucfirst($month_name)).' '.$year;  #note that some locales don't capitalize month and day names

#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table align="center" valign="top" width="100%">'."\n".
'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";

if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
foreach($day_names as $d)
$calendar .= '<th class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

#create notice for Holidays, Events & Birthdays.

if (ssi_todaysHolidays('')) {
  echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center" style="color: #000000;"><b>Holiday Today</b></td><td><hr></td></tr><td colspan="7" class="windowbg" ><span class="smalltext">';
  ssi_todaysHolidays();
  echo '</span></td></tr>';
}


if (ssi_todaysEvents('')) {
  echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center" style="color: #000000;"><b>Special Events Today</b></td><td><hr></td></tr><td colspan="7" class="windowbg" ><span class="smalltext">';
  ssi_todaysEvents();
  echo '</span></td></tr>';
}

if (ssi_todaysBirthdays('')) {
  echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center" style="color: #000000;"><b>Birthdays Today</b></td><td><hr></td></tr><td colspan="7" class="windowbg" ><span class="smalltext">';
  ssi_todaysBirthdays();
  echo '</span></td></tr>';
}
echo '</table>';

RoarinRow

Very cool londonhogfan  :up:

SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0

This website is proudly hosted on Crocweb Cloud Website Hosting.