PHP help needed again please!

Oct 19, 2000
17,861
4
81
I have the SMF forum package installed on my site, and I'm using the SSI file to bring back info to my main homepage. The particular function that I'm having trouble with is the calendar, which reports back any upcoming holiday, birthdays, and events.

When any one of the three have an upcoming notice, everything is perfectly fine. For example, if there is an upcoming holiday, it will display "Upcoming Holidays: Christmas, Upcoming Birthdays: None, Upcoming Events: None". However, when none of the three have anything upcoming, the entire thing disappears.

I've attached the current code using the "Attach Code" button.

So what exactly is going on here? To me, I think that when that array with birthdays, holidays, and events is blank, that everything should display as "Upcoming *: None". However, I'm still starting out with PHP, and I'm not really sure what's going on with the setting of the global variables and the argument in the function.

I've attempted adding the following at the very end...

if (empty($context['calendar_holidays'] && $context['calendar_birthdays'] && $context['calendar_events'])) { echo 'nothing to display blah blah'; }

...but that only causes my entire page to not load. Errors are turned off, so I guess I could turn those on to see what the actual error is.

Can anybody give me any insight? I really wanted to figure this out on my own, but I've had no luck over the past couple of days.

EDIT: Since that attach code funciton just jumbles everything together, here's a screen cap of the function so it's easier to read and interpret:

http://pics.bbzzdd.com/users/blurredvision/code.JPG

EDIT2: Editing the first time had truncated what I put in the code box, so disregard that altogether.
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
i applaud your desire for figuring it out on your own

here's some tips.

dump your array to see whats really going on
on line 1181 do this:
echo "<xmp";
print_r($context);
echo "</xmp>";
die();

that will show you whats really in the context array

also, if all are empty and nothing is getting output, comment out any returns (one by one) to find which condition is returning
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
btw, the attach code button really sucks

kinda ironic that this is one of the most tech savvy communities on the net
 

Cerebus451

Golden Member
Nov 30, 2000
1,425
0
76
Just a guess here:

If there are no upcoming holidays/birthdays/events, is it possible that the first call to smf_LoadCalendarInfo is returning false, causing the function to return an empty array at that point?

You could add code at that point that says if $output_method == 'echo', then copy the three echo statements in the else clauses to print out the 'None's, then return the empty array.
 
Oct 19, 2000
17,861
4
81
I'll give each of these suggestions a try this evening. Thanks so far for the help and suggestions, I appreciate it.
 

nakedfrog

No Lifer
Apr 3, 2001
58,570
12,874
136
Originally posted by: Cerebus451
Just a guess here:

If there are no upcoming holidays/birthdays/events, is it possible that the first call to smf_LoadCalendarInfo is returning false, causing the function to return an empty array at that point?

I only looked at it briefly, but that was my first guess.
 
Oct 19, 2000
17,861
4
81
Yes, I finally got it figured out, thanks to the help from Cerebus451 (and nakedfrog, since you concured ). The thing I was tripped up on was that I didn't realize the following piece of code...

if (!smf_loadCalendarInfo())
return array();

...was calling on a function until I deduced that from Cerebus' sentence. What gives it away that it's a function, the () at the end of it?

Anyway, once I realized that was a function, I found it in the SSI file, then checked out the code, and found this:

if (empty($holidays) && empty($bday) && empty($events))
return false;

So I changed the return to an echo, and voila!

Thanks a ton guys, I learned a lot with this problem!
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |