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: 378
  • Total: 378

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.

Ken.

True, but look at the potential for learning.  :)
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

Murgen

True, my Master. I have been looking into the script and the b-days settings from the members involved and so far I haven't got a clue. Can't pin the error at the moment. B-day June 1 goes wrong and B-day June 2 is listed the right way. Intriguing little bug.

Murgen

Hi all,

I use the calendar script from http://www.tinyportal.net/index.php?topic=700.520 (page 53, post Ken) and I have been looking into it for such a long time my eyes and head hurt. There is a bug with shows in the birthday section. Some birthdays show as January 1st. I tried to figure out if it has to do with leapyears but no luck there. I just can't figure it out. :(



The thing is that the other sections do not show the bug. For instance: the wrong birthday entry is June 15th which shows well in the Father's day entry.

I can read php-scripts. It is not easy for me but I can work it out (47 yrs old << Basic, Pascal, Modula-2 generation). The bug shows on several birthdays but the majority shows up the right way. It is not logical and would love some advice where to look and check in the script.

Thank you.

Murgen

Fixed!

At page http://www.tinyportal.net/index.php?topic=700.190 J.A. Cortina lists a fixed code! Ken posted the unfixed version of that particular code.

Timestamp problem as documented by my hero J.A. Cortina.
Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. PHP 5.1.0 and newer versions overcome this limitation though.

Vivasvan

#534
Hi

I have read through the whole thread.  I have nearly found what I want.  ... I want to use this particular code that i found.  It fits perfect and looks extremely neat.  However there are just a few things I need adding and I cant seem to do it.   

What i need adding to this is really really simple and you code gurus could easily do it.. i have tried.. and its a mess when i do.

1. Date next to event Jun xx  or XX/XX format will do.
2. Upcoming Events is listed twice.. once as a header then again in green before the event.  I just want the date there and dont want it listed twice.
3. Post event link at the bottom below the events listed.
4. I dont want holidays listed etc.. Just events.  It shows dday holiday on todays date 06/06.  I just want events.
5. When someone clicks on a date it would be nice if it goes to the calender smf page and not straight to posting event screen.

Can anyone just do this in the code ive listed below.  I have really been through all this section and found various calenders some do what i want but dont look good on my site and most if not all have the holiday/bdays stuff in them. I just want events.

Here is my site : www.orderofmiddleearth.com

It would be awesome if this could be done.

here is the code im using: global $scripturl;
$now = mktime();
         $today = date('j',$now);
         $year = date("Y",$now);
         $month = date("n",$now);
         $days = array($today=>array(NULL,NULL,'<a align="center" style="color: steelblue; font-weight: bold; border: solid 1px black; background-color: white; padding: 2px 4px 2px 4px; font-size: xx-small; font-family: verdana, sans-serif;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));

         $day_name_length = 3;
         $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 style=" font-size: xx-small; font-family: verdana, sans-serif;">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span style="font-size: xx-small; font-family: verdana, sans-serif;">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table>'."\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 style=" font-size: xx-small; font-family: verdana, sans-serif;" 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 style=" font-size: xx-small; font-family: verdana, sans-serif;" 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 style=\"padding-right: 4px; font-size: xx-small; font-family: verdana, sans-serif;\"  onmouseover=\"this.style.backgroundColor='#ededed'\" onMouseOut=\"this.style.backgroundColor=''\"><a";
if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td style=" font-size: xx-small; font-family: verdana, sans-serif;" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
echo $calendar.'</tr>';

if (ssi_todaysBirthdays('')) {
  echo '<tr><td><hr></td><td colspan="5" style=" font-size: xx-small; font-family: verdana, sans-serif;" align="center">Birthdays</td><td><hr></td></tr><td colspan="7" class="calendarblock">';
  ssi_todaysBirthdays();
  echo '</td></tr>';
}

if (ssi_todaysCalendar('')) {
  echo '<tr><td><hr></td><td colspan="5" style=" font-size: xx-small; font-family: verdana, sans-serif;" align="center">Upcoming Events</td><td><hr></td></tr><td colspan="7" style=" font-size: xx-small; font-family: verdana, sans-serif;">';
  ssi_todaysCalendar();
  echo '</td></tr></table>';
}



JPDeni

Why don't you use the "Calendar in a php block" code?

Vivasvan

#536
Hi

Im a bit confused..... i thought i was using it.   :idiot2:

where is the one your refering to....but ive noticed on this thread.... there are two headings....

Problem with calendar-code
then most replys are too  calendar in php block  and i cant find this thread.

JPDeni

I think I'm confused, too, then. I didn't realize that the name of the topic was changed. Sorry.

The code looks different than the first code in the topic, though. I've used the code that Bloc wrote with good results.

Vivasvan

#538
Hi again...

yes the first code doesnt display the things i wanted in the calender.  The code im using is a few pages into this thread. On page9 at the bottom (Xarcells code) and its the code on the bottom of the page. Its neater and fits perfect.  Its just tweaked from from the first one.

I just wanted these additions to the calendar code im using.

1. Date next to event Jun xx  or XX/XX format will do.
2. Upcoming Events is listed twice.. once as a header then again in green before the event.  I just want the date there and dont want it listed twice.
3. Post event link at the bottom below the events listed.
4. I dont want holidays listed etc.. Just events.  It shows dday holiday on todays date 06/06.  I just want events.
5. When someone clicks on a date it would be nice if it goes to the calender smf page and not straight to posting event screen.

I cant seem to do it.  Someone here must know where the code lines fit in.   Here is the code again

global $scripturl;
$now = mktime();
         $today = date('j',$now);
         $year = date("Y",$now);
         $month = date("n",$now);
         $days = array($today=>array(NULL,NULL,'<a align="center" style="color: steelblue; font-weight: bold; border: solid 1px black; background-color: white; padding: 2px 4px 2px 4px; font-size: xx-small; font-family: verdana, sans-serif;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));

         $day_name_length = 3;
         $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 style=" font-size: xx-small; font-family: verdana, sans-serif;">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span style="font-size: xx-small; font-family: verdana, sans-serif;">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table>'."\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 style=" font-size: xx-small; font-family: verdana, sans-serif;" 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 style=" font-size: xx-small; font-family: verdana, sans-serif;" 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 style=\"padding-right: 4px; font-size: xx-small; font-family: verdana, sans-serif;\"  onmouseover=\"this.style.backgroundColor='#ededed'\" onMouseOut=\"this.style.backgroundColor=''\"><a";
if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td style=" font-size: xx-small; font-family: verdana, sans-serif;" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
echo $calendar.'</tr>';

if (ssi_todaysBirthdays('')) {
  echo '<tr><td><hr></td><td colspan="5" style=" font-size: xx-small; font-family: verdana, sans-serif;" align="center">Birthdays</td><td><hr></td></tr><td colspan="7" class="calendarblock">';
  ssi_todaysBirthdays();
  echo '</td></tr>';
}

if (ssi_todaysCalendar('')) {
  echo '<tr><td><hr></td><td colspan="5" style=" font-size: xx-small; font-family: verdana, sans-serif;" align="center">Upcoming Events</td><td><hr></td></tr><td colspan="7" style=" font-size: xx-small; font-family: verdana, sans-serif;">';
  ssi_todaysCalendar();
  echo '</td></tr></table>';
}


ps something very strange has happened on the above code.  The calendar was working fine while an event was showing... now today is the first day without an upcoming event... and the calandar box has split!! the calander is right at the bottom of the page.. yet the box title heading is where the calendar was displayed before... on the upper right of the page... whats happened... this code is the only one that does this on my site (www.orderofmiddleearth.com).. all the others work fine.  However this is the best looking of the calendars and i really want to use it...

can anyone help with the things i want? 

Xarcell

I looked at the code at the above URL, I don't see any issues. What am I missing?

This website is proudly hosted on Crocweb Cloud Website Hosting.