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: 629
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 396
  • Total: 396

SMF Calendar Block

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

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

truelight5

I love this mod, and it is installed perfectly on my site, however, I am having something strange happen that was mentioned earlier in this thread but I never saw an answer for this issue.

When the calendar block is on I have a box above every single post that says "Linked Events" and has the "event link" there...but the events are not obviously linked to EVERY post on the forum...lol so there has to be an issue I am missing.

In the Calendar options (for the SMF part) I have the following UNchecked:
Show linked events in topic display:

The software I am running is:

SMF 1.1 RC3 TinyPortal v0.9.5

I would be so thankful for any help you could provide! 

Blessings!
Susie 

jacortina

There's 22 pages in this thread and a number of different calendar block versions.

Which one are you using?

truelight5

I am so sorry about that, duh... :idiot2:

This is the code I am currently using:

global $scripturl, $modSettings, $sdays;

$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date("Y",$now);
if (isset($_REQUEST['month'])) {
$month = $_REQUEST['month'];
} else {
$month = date("n",$now);
}

#create notice for Holidays, Events & Birthdays.

if (ssi_rafy_todaysBirthdays('')) {
echo '<div align="center" class="smalltext" style="font-weight: bold;" color: #' . $modSettings['cal_bdaycolor'] . ';">Birthdays</div>';
echo '<span class="smalltext">';
$birthdays = split(',', ssi_rafy_todaysBirthdays('echo', $month));
echo '</span>';

echo '<hr style="border: 1px solid #7C5401" />';
}

if (ssi_rafy_todaysEvents('')) {
echo '<div align="center" class="smalltext" style="font-weight: bold; color: #' . $modSettings['cal_eventcolor'] . ';">Upcoming Events</div>';
echo '<span class="smalltext">';
$events = split(',', ssi_rafy_todaysEvents('echo', $month));
echo '</span>';

echo '<hr style="border: 1px solid #7C5401" />';
}

if (ssi_rafy_todaysHolidays('')) {
echo '<div align="center" class="smalltext" style="font-weight: bold; color: #' . $modSettings['cal_holidaycolor'] . ';">Holidays</div>';
echo '<span class="smalltext">';
$holidays = split(',', ssi_rafy_todaysHolidays('echo', $month));
echo '</span>';

echo '<hr style="border: 1px solid #7C5401" />';
}


//list($eventday, $eventlink) = each($events);
//echo '<hr>';
//foreach($holidays as $ed){
// $event = split('=>', $ed);
// echo $event[0].$event[1];
//}
//echo '<hr>';

$days = array($today=>array(''.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'',NULL,'<span style="font-weight: bold; border: solid 1px white; padding: 0px 0px 0px 0px;">'.$today.'</span>'));

$day_name_length = 1;
$month_href = $scripturl . '?action=calendar&month=' . $month;
$first_day = 0;
$pn = array('ÂÃ,«Ã‚Ã,«Ã‚Ã,«'=>$scripturl.'?month='.($month-1), 'ÂÃ,»Ã‚Ã,»Ã‚Ã,»'=>$scripturl.'?month='.($month+'1'));

$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 class="smalltext" 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:center;\">";
}

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++){
$sp1 = '';
$sp2 = '';
foreach($holidays as $sd) {
$event = split('=>', $sd);
if($day == intval($event[0]))
{
$sp1 = '<span align="center" style="color: #FFFFFF; background-color: #' . $modSettings['cal_holidaycolor'] . '; padding: 0px 0px 0px 0px;" title="'.htmlspecialchars($event[1]).'">';
$sp2 = '</span>';
}
}
foreach($events as $sd) {
$event = split('=>', $sd);
if($day == intval($event[0]))
{
$sp1 = '<span align="center" style="color: #FFFFFF; background-color: #' . $modSettings['cal_eventcolor'] . '; padding: 0px 0px 0px 0px;" title="'.htmlspecialchars($event[1]).'">';
$sp2 = '</span>';
}
}
foreach($birthdays as $sd) {
$event = split('=>', $sd);
if($day == intval($sd))
{
$sp1 = '<span align="center" style="color: #FFFFFF; background-color: #' . $modSettings['cal_bdaycolor'] . '; padding: 0px 0px 0px 0px;" title="'.htmlspecialchars($event[1]).'">';
$sp2 = '</span>';
}
}
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:center;\">";
}
if(isset($days[$day]) and is_array($days[$day]) and ($month == date("n",$now))){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>');
$calendar .= ($link ? '<a href="'.htmlspecialchars($link).'">'.$sp1.$content.$sp2.'</a>' : $sp1.$content.$sp2).'</td>';
}
else
{
$calendar .= "<td style=\"padding-right: 0px; font-size: x-small; font-family: arial, sans-serif;\"><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\">$sp1$day$sp2</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days
echo $calendar.'</tr>';
echo '</table>';

// Show today's birthdays.
function ssi_rafy_todaysBirthdays($output_method = 'echo', $month)
{
global $context, $scripturl, $db_prefix;

if (!smf_loadCalendarInfo() || empty($context['calendar_birthdays']))
return array();

if ($output_method != 'echo')
return $context['calendar_birthdays'];

foreach ($context['calendar_birthdays'] as $member)
{
$query = db_query(
"SELECT birthdate
FROM {$db_prefix}members
WHERE ID_MEMBER='".$member['id']."'", __FILE__, __LINE__);

$row = mysql_fetch_assoc($query);
$birthdate = strtotime($row['birthdate']);

echo '<div align="center">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$birthdate) . '"><strong>' . date("F jS",$birthdate) . '</strong></a>';
echo '<br />';
echo '<img src="/Themes/rOrb/images/icons/birthday_small.gif" width="13" height="17" align="absmiddle" hspace="5">';
echo '<a href="', $scripturl, '?action=profile;u=', $member['id'], '">';
echo $member['name'] . (isset($member['age']) ? ' (' . $member['age'] . ')' : '');
echo '</a>';
// echo (!$member['is_last'] ? '<br>' : '');

echo '</div>';

if(date("n",$birthdate) == $month)
{
$sdays .= date("j",$birthdate).'=>'.$member['name'].'ÂÃ,´s bDay'.',';
}
}
return $sdays;
}

// Show today's events.
function ssi_rafy_todaysEvents($output_method = 'echo', $month)
{
global $context, $db_prefix;

if (!smf_loadCalendarInfo() || empty($context['calendar_events']))
return array();

if ($output_method != 'echo')
return $context['calendar_events'];

foreach ($context['calendar_events'] as $event)
{
$query = db_query(
"SELECT startDate
FROM {$db_prefix}calendar
WHERE ID_EVENT='".$event['id']."'", __FILE__, __LINE__);

$row = mysql_fetch_assoc($query);
$startDate = strtotime($row['startDate']);

echo '<div align="center">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$startDate) . '"><strong>' . date("F jS Y",$startDate) . '</strong></a>';
echo '<br />';

if ($event['can_edit'])
echo '<a href="' . $event['modify_href'] . '" style="color: #FF0000;">[e]</a> ';
echo $event['link'] ;
// echo (!$event['is_last'] ? '<br>' : '');
echo '</div>';

if(date("n",$startDate) == $month)
{
$sdays .= date("j",$startDate).'=>'.str_replace("'","ÂÃ,´",$event['link']).',';
}
}
return $sdays;
}

// Show today's holidays.
function ssi_rafy_todaysHolidays($output_method = 'echo', $month)
{
global $context;

if (!smf_loadCalendarInfo() || empty($context['calendar_holidays']))
return array();

if ($output_method != 'echo')
return $context['calendar_holidays'];


foreach($context['calendar_holidays'] as $holiday) {
$query = db_query(
"SELECT eventDate
FROM {$db_prefix}smf_calendar_holidays
WHERE title='".str_replace("'","''",$holiday)."'
AND (eventDate LIKE '".date("Y")."%' OR eventDate LIKE '0004%')", __FILE__, __LINE__);

$row = mysql_fetch_assoc($query);
$eventDate = strtotime($row['eventDate']);

echo '<div align="center">';
echo '<a href="', $scripturl, '?action=calendar;year=' . date("Y") . ';month=' . date("n",$eventDate) . '"><strong>' . date("F jS",$eventDate) . '</strong></a>';
echo '<br />';
echo $holiday;
echo '</div>';

if(date("n",$eventDate) == $month)
{
$sdays .= date("j",$eventDate).'=>'.str_replace("'","ÂÃ,´",$holiday).',';
}
}
return $sdays;
}



Thanks in advance for any help you can offer  ;)

jacortina

This wasn't the block I posted (and tweaked), though it has a lot of the same code.

But when I put this in my test site, I can't reproduce the condition you describe. Event link only shows above topic it's linked to and it doesn't even show there when I uncheck 'Show linked events in topic display:'.

Are you using the default theme? Do you mean event links above every post or at top of every topic?

truelight5

No I am using a modified theme...I sent you a PM with the info to access the board in it =o)

Thanks!

jacortina

The issue was resolved. And for anybody else who is having an issue where linked events are appearing in every topic, you should check the Display.template.php in the theme you're using. If it retains the original comment, there's a section headed up with:

// Does this topic have some events linked to it?

The 'if' clause following that outputs the table containing events. In this case here, the 'if' clause and the 'foreach' loop a few lines down were referencing $context['calendar_events']. They should be referencing $context['linked_calendar_events']. Changing those two statements to reference the correct array cleared up the problem.

truelight5

And BIG thanks to jacortina for going to my site and helping me figure this out!! I wouldn't have thought to look in the Display file. 


Where is that clapping hands jumping up and down with profuse gratitude smilie??

THANKS again Jacortina!

Blessings!
Susie

Giddeaon

Quote from: jacortina on October 05, 2006, 01:34:20 PM
The issue was resolved. And for anybody else who is having an issue where linked events are appearing in every topic, you should check the Display.template.php in the theme you're using. If it retains the original comment, there's a section headed up with:

// Does this topic have some events linked to it?

The 'if' clause following that outputs the table containing events. In this case here, the 'if' clause and the 'foreach' loop a few lines down were referencing $context['calendar_events']. They should be referencing $context['linked_calendar_events']. Changing those two statements to reference the correct array cleared up the problem.

That just fixed an annoying bug that has been plaguing me since I added that calendar block.  Thank you.

zeniitti

Here is conversation about changing language of the days etc. to local language: http://www.tinyportal.net/smf/index.php?topic=700.msg30037#msg30037 Any news how to do it? Gave it a little time and space, but I didn't hack it.

Another thing: is it possible to have upcoming weeks event rather than only one day? Would like to have like Next 7 days evetns or something like that.

tnx

keith021773

In the events section of the code.  Is there a way to make it so that when you post you have more days for it to show?  I was wanting it to be able to show for at least one mth.  30 days or so..    For instance when a tv show or a game is coming out it could show it in the events section for 30 days...   I hope this makes sense.   LOL

This website is proudly hosted on Crocweb Cloud Website Hosting.