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

Recent

Welcome to TinyPortal. Please login or sign up.

April 30, 2024, 06:56:32 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 147
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 99
  • Total: 99

SMF Calendar Block

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

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ZarPrime

mariusfv,

Each of your members, in the "Look and Layout" preferences of their profile, has the ability to auto detect the "Time Offset:" for their local computer from the server tme.

ZarPrime

mariusfv

Yes...but in Block the date it change after 5 hours !(server time) i test this with my account ....and when my time is 12.30(night) the date must change in block but it change only after 5 hours....try clear coookie...log out etc....so in block is problem....it change only after 5 hours....server time...

pvcblue

Quote from: mariusfv on May 30, 2010, 05:13:24 PM
Yes...but in Block the date it change after 5 hours !(server time) i test this with my account ....and when my time is 12.30(night) the date must change in block but it change only after 5 hours....try clear coookie...log out etc....so in block is problem....it change only after 5 hours....server time...

Have you tried setting your server time to your time in the Admin>Features and Options>Overall time offset   ???

"Smurfs, Smurfs, and More Smurfs!"

ZarPrime

mariusfv,

Please post the exact code you are using here so that one of us can try it on one of our test forums.  Please use the bbc code tags (#) to post the code.

ZarPrime

mariusfv

#614
Edit:
Problem Solved !

In Overall time offset +8 solve the problem(that was difference between server time and forum time) !

10x for information !

Smythe

Listed below is the code that I am using...

I would like to have the calendar block NOT show the holidays.... just events ...that's it.... I know how to remove the birthdays.... for the life of me I can't get the holidays out of there...thanks in advance ( also if you know how i could get it to show one event per line vs. all of them in a row separated by comas.... that would be great too....)

global $scripturl;
$now = mktime();
         $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 0px 0px 0px;" 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 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>'."\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;sa=post;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>';

if (ssi_todaysBirthdays('')) {
  echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center">Birthdays</td><td><hr></td></tr><td colspan="7" class="smalltext">';
  ssi_todaysBirthdays();
  echo '</td></tr>';
}

if (ssi_todaysCalendar('')) {
  echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center">Upcoming Events</td><td><hr></td></tr><td colspan="7" class="smalltext">';
  ssi_todaysCalendar();
  echo '</td></tr>';
}

echo '</table>';

IchBin

This is the section for events that you can comment out or remove:
if (ssi_todaysCalendar('')) {
  echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center">Upcoming Events</td><td><hr></td></tr><td colspan="7" class="smalltext">';
  ssi_todaysCalendar();
  echo '</td></tr>';
}


To change the output of the birthdays you have to add some code. This isn't tested, so let me know if there's any problems.
Find this:
if (ssi_todaysBirthdays('')) {
  echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center">Birthdays</td><td><hr></td></tr><td colspan="7" class="smalltext">';
  ssi_todaysBirthdays();
  echo '</td></tr>';
}


Replace with this:
$birthdayList = ssi_todaysBirthdays('array');

if ($birthdayList) {
foreach ($birthdayList as $member)
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '"><span class="fix_rtl_names">' . $member['name'] . '</span>' . (isset($member['age']) ? ' (' . $member['age'] . ')' : '') . '</a>' . (!$member['is_last'] ? '<br />' : '');
}

Smythe

I think maybe I didn't explain my request enuff....

NO Birthdays...
NO Holidays

ONLY Events...



Would like Ground Hogs Day and Valentines Day to go away....

also would like to have the "Upcoming Events" displayed once... I think I got that one but then would like to have the events listed one per line

test event 1
test event 2
test event 3

vs test event 1, test event 2, test event 3... etc

thanks for the quick response on my prior request...

ZarPrime

All of these are valid ssi calls ...


  • ssi_todaysBirthdays();
  • ssi_todaysHolidays();
  • ssi_todaysEvents();
  • ssi_todaysCalendar();

The last one is a combination of all 3 of the first.  If you only want the events then just use the third one.  The ssi functions, when using the default echo, will display each one right after the other one in a single line.  If you want each event to be on a separate line, you will have to use array rather than echo and write the code with a line break accordingly.

ZarPrime

Smythe

#619
Sorry to be a pain... I am not sure how to write the code for the array for calendar events..

I would greatly appreciate it if someone much smarter then I would lend a hand....lol ... smf 2.0.2

Thanks so much for the help thus far... it is greatly appreciated