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,973
  • Latest: NonStop
Stats
  • Total Posts: 196,234
  • Total Topics: 21,353
  • Online today: 606
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 451
  • Total: 451

Calendar

Started by stang7043, August 11, 2010, 07:07:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sI-IoBi3

Hi ,
So i've been looking around using differnt codes to get my calendar to work but nothing doing  :(

I've tried using the block code snippet, the calendar block shows with no calendar?

so i've tried this code i found on this forum :
global $scripturl, $modSettings;         $now = mktime() + $modSettings['time_offset'] * 3600;         $today = date('j',$now);         $days = array($today=>array(NULL,NULL,'<span class="windowbg3" style="color: white; font-weight: normal; font-size: x-small; border: solid 1px white; padding: 0px 4px 0px 4px;">'.$today.'</span>'));         $year = date("Y",$now);         $month = date("n",$now);         $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>'.'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n.'</caption><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=\"windowbg\" style=\"padding-right: 4px; font-size: xx-small; font-family: verdana, sans-serif;\" ><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" daysecho $calendar.'</tr>';#create notice for Holidays, Events & Birthdays.if (ssi_todaysHolidays('')) {  echo '<tr><td>
</td><td colspan="5" class="smalltext" align="center" style="color: #000000;">Holiday Today</td><td>
</td></tr><td colspan="7" class="windowbg" ><span class="smalltext">';  ssi_todaysHolidays();  echo '</span></td></tr>';}if (ssi_todaysEvents('')) {  echo '<tr><td>
</td><td colspan="5" class="smalltext" align="center" style="color: #000000;">Special Events Today</td><td>
</td></tr><td colspan="7" class="windowbg" ><span class="smalltext">';  ssi_todaysEvents();  echo '</span></td></tr>';}if (ssi_todaysBirthdays('')) {  echo '<tr><td>
</td><td colspan="5" class="smalltext" align="center" style="color: #000000;">Birthdays Today</td><td>
</td></tr><td colspan="7" class="windowbg" ><span class="smalltext">';  ssi_todaysBirthdays();  echo '</span></td></tr>';}echo '</table>';

and no luck

can anyone help me?

ZarPrime

sI-IoBi3,

Please read the Posting Guidelines, specifically What versions of SMF and TinyPortal are you using.

Also, when posting code in your posts, please use the bbc code tags (#) to surround the code,
like this ...


This is code surrounded by bbc code tags


ZarPrime

sI-IoBi3

Ah sorry  :-[


Link to my site: http://www.wowspaces.com
TP version: 1.102
Default Forum Language: english
Theme name and version: blackrain v2
Browser Name and Version: chrome latest

the php code i have currently for calendar block is:

global $scripturl, $modSettings;         $now = mktime() + $modSettings['time_offset'] * 3600;         $today = date('j',$now);         $days = array($today=>array(NULL,NULL,'<span class="windowbg3" style="color: white; font-weight: normal; font-size: x-small; border: solid 1px white; padding: 0px 4px 0px 4px;">'.$today.'</span>'));         $year = date("Y",$now);         $month = date("n",$now);         $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>'.'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n.'</caption><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=\"windowbg\" style=\"padding-right: 4px; font-size: xx-small; font-family: verdana, sans-serif;\" ><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" daysecho $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>';   


sI-IoBi3

that didn't work out right lol
is there a code right now I can put into the calendar php block that works?
many thanks

WillyP

Do you have the calender enabled in SMF?

sI-IoBi3

Quote from: WillyP on December 22, 2010, 04:23:10 PM
Do you have the calender enabled in SMF?

yes, do I have to disable smf calendar?

WillyP

No, it needs to be enabled.  Just noticed nobody had mentioned it.  As far as I know, any blockcode uses the SMF calender and won't work without it.

ZarPrime

I needed to see what version of SMF you were running as well.  However, I got it by looking at your site.

Can you please give us a link to the post where you found the block code snippet that you are using?

ZarPrime

sI-IoBi3

Hi this is the link: http://www.tinyportal.net/index.php?topic=700.msg263137#msg263137

It is posted by phil serna as a quote on page 61 [originally posted by ken]

ZarPrime

OK, well, I had done some of the edits to make the mini-calendar block work fine with SMF 2.0 and you can see what it looks like on our FrontPage here on this site.  I had thought that the old code would work fine with SMF 1.1.X and the latest TinyPortal without any edits but I guess I was wrong.  Right now, I don't have a test site running SMF 1.1.12 and the latest TinyPortal up and running.  Sometime after Christmas, I will see if I can go ahead and setup an SMF 1.1.12 test site and see if I can look at what edits need to be done to make the mini-calendar code work properly.

Give us some time to enjoy the holidays and then we'll see what we can do. ;)

ZarPrime

This website is proudly hosted on Crocweb Cloud Website Hosting.