TinyPortal

Development => Support => Topic started by: stang7043 on August 11, 2010, 07:07:57 PM

Title: Calendar
Post by: stang7043 on August 11, 2010, 07:07:57 PM
I hope this is in the right section if not admins please move it to the correct forum. Ok so on to my question......

I would like to have the calendar at my site to be displayed similar to the way the calendar is displayed here on the frontpage. For the life of me I cant figure out how to accomplish this.

Im running SMF 1.1.11 & TinyPortal v1.0 beta 3 (on a side note would it be worth it to upgrade to 5.2 ?)

Thanks in advance.

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fimg153.imageshack.us%2Fimg153%2F9778%2Fcapturety.jpg&hash=391280f2cf1cbefa8169c13dcaf27f8c21c7802b) (http://img153.imageshack.us/i/capturety.jpg/)

Title: Re: Calendar
Post by: Lesmond on August 11, 2010, 07:26:46 PM
I you search for Calendar, There are a few floating around, also try your search in... Resources Ã,» Block code support
Title: Re: Calendar
Post by: stang7043 on August 11, 2010, 07:29:39 PM
Thanks. Was wondering if it was just a simple coding issue or if I was missing something in the calendar bloc/panel.

Appreciate the quick response.
Title: Re: Calendar
Post by: stang7043 on August 11, 2010, 08:19:03 PM
ok I found this http://www.tinyportal.net/index.php?topic=32717.msg262975#msg262975 but Im not sure what is meant by "Here's the code and it goes in a php block ..." Do I add that script to the current calendar.php ?

Sorry im a complete noob....  :-\
Title: Re: Calendar
Post by: Lesmond on August 11, 2010, 08:26:17 PM
You add it to a PHP block, in your tinyportal admin, block manager
Title: Re: Calendar
Post by: stang7043 on August 11, 2010, 08:42:08 PM
ok Im an idiot.  :uglystupid2:

When I activate the block I get
Fatal error: Call to undefined function getBirthdayRange() in /home/content/site/html/Sources/Load.php(1742) : eval()'d code(48) : eval()'d code on line 236

The load php is in the correct location.

Title: Re: Calendar
Post by: stang7043 on August 11, 2010, 09:10:30 PM
Got it working with this code. Well at least it is displaying need to test it. Thanks for the help and patience.

Quote from: Herr Inoddorell on January 08, 2009, 11:49:02 PM
Hi to all, I'm using this Code:

Title: Re: Calendar
Post by: Lesmond on August 11, 2010, 09:39:54 PM
Glad you got it sorted, their is a few variation to the calendar code going around. 
Title: Re: Calendar
Post by: ZarPrime on August 13, 2010, 02:00:00 AM
stang7043,

The code that I posted at the link you posted in the 4th post in this topic is specifically for SMF 2.0 RC3 and the latest TinyPortal.  It won't work correctly with SMF 1.1.11 and TP 1.0 beta 3.  In any case, I'm glad you solved the issue on your own and I will now mark this topic solved. O0

ZarPrime 
Title: Re: Calendar
Post by: stang7043 on August 13, 2010, 05:23:15 PM
Quote from: ZarPrime on August 13, 2010, 02:00:00 AM
stang7043,

The code that I posted at the link you posted in the 4th post in this topic is specifically for SMF 2.0 RC3 and the latest TinyPortal.  It won't work correctly with SMF 1.1.11 and TP 1.0 beta 3.  In any case, I'm glad you solved the issue on your own and I will now mark this topic solved. O0

ZarPrime

yeah I just noticed the script requirements. Absolutely mark the solved. Appreciate all the help.
Title: Re: Calendar
Post by: sI-IoBi3 on December 22, 2010, 01:57:38 PM
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?
Title: Re: Calendar
Post by: ZarPrime on December 22, 2010, 02:30:41 PM
sI-IoBi3,

Please read the Posting Guidelines (http://www.tinyportal.net/index.php?topic=581), 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
Title: Re: Calendar
Post by: sI-IoBi3 on December 22, 2010, 03:40:16 PM
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>';   

Title: Re: Calendar
Post by: sI-IoBi3 on December 22, 2010, 03:41:12 PM
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
Title: Re: Calendar
Post by: WillyP on December 22, 2010, 04:23:10 PM
Do you have the calender enabled in SMF?
Title: Re: Calendar
Post by: sI-IoBi3 on December 22, 2010, 04:29:42 PM
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?
Title: Re: Calendar
Post by: WillyP on December 22, 2010, 04:35:48 PM
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.
Title: Re: Calendar
Post by: ZarPrime on December 22, 2010, 05:42:07 PM
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
Title: Re: Calendar
Post by: sI-IoBi3 on December 22, 2010, 06:45:06 PM
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]
Title: Re: Calendar
Post by: ZarPrime on December 23, 2010, 02:09:10 PM
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
Title: Re: Calendar
Post by: NoFeaR on January 18, 2011, 01:00:30 PM
How can i list all the events that is in my calender?? I don't want only 1 months events. I want all. is it possible by any chance?
Title: Re: Calendar
Post by: ZarPrime on January 18, 2011, 02:46:31 PM
NoFeaR,

I have no idea what version of SMF and what version of TinyPortal you are using but there are switches in most of the mini-calendar code snippets that shoud allow you to do this.  Look for something like the below in the code you are using.  Change "$show_events_past = false" to true and then select the number of days to look back ...


// Choose to show 'look-behind' for the various entry types
$show_bdays_past = false;
$show_events_past = false;
$show_hdays_past = false;

// For any of the above chosen, days prior to today to display -
//    use '0' (zero) to use beginning of current month
$past_look_behind_period = 0;


ZarPrime
Title: Re: Calendar
Post by: NoFeaR on January 18, 2011, 02:59:43 PM
Thanks. you are a life saver