Log in

View Full Version : Show Events on non-vb page


Dave#
08-09-2001, 08:26 AM
I will pay anyone who can modify the following hack

http://vbulletin.com/forum/showthread.php?threadid=21232

to do the following


Run as a standalone script for inclusion in a non VB page
Be able to pull the next 5 events from the callendar (not just todays events) from todays date (including todays events)


Payment is open to negotiation but this is an urgent requirement.

Payment will be via one of the following options depending on how you want paid


paypal
cheque
bank transfer


Please PM me asap to get this work.

Please state:

a) The cost
b) the timescales

Thanks

Dave Campbell www.cpfc.org

sysmom
08-09-2001, 02:03 PM
I'll bet Dave has a bigger budget than I do, but I'm pretty interested in this, as well.

Not neccesarily just the next 5 events, but the listings over the next X number of days would be good, too.

-deb

boatdesign
08-11-2001, 01:41 PM
Me too!

Would love a mod which would show the next x events or events for the next x days on my homepage...

Freddie Bingham
08-11-2001, 06:58 PM
<?php

include('./global.php');

$events = $DB_site->query("SELECT event, eventdate, eventid, subject
FROM calendar_events
WHERE public = 1 AND eventdate >= '".vbdate('Y-m-d',time())."'
ORDER BY eventdate LIMIT 5");
if ($DB_site->num_rows($events)) {
echo "Next Five Events:<br>";
while ($event = $DB_site->fetch_array($events)) {
echo "<a href='calendar.php?s=$session[sessionhash]&action=getinfo&eventid=".$event['eventid']."'>".$event['subject']."</a><br>";
}
} else {
echo "No Events";
}
?>It should even be Kier approved in terms of quoted array indices but it may be subject to correction.

Dave#
08-11-2001, 07:18 PM
Originally posted by freddie
<?php

include('./global.php');

$events = $DB_site->query("SELECT event, eventdate, eventid, subject
FROM calendar_events
WHERE public = 1 AND eventdate >= NOW()
ORDER BY eventdate LIMIT 5");
if ($DB_site->num_rows($events)) {
echo "Next Five Events:<br>";
while ($event = $DB_site->fetch_array($events)) {
echo "<a href='calendar.php?s=".$session['sessionhash']."&action=getinfo&eventid=".$event['eventid']."'>".$event['subject']."</a><br>";
}
} else {
echo "No Events";
}
?>It should even be Kier approved in terms of quoted array indices but it may be subject to correction.

You really can't imagine how happy this makes me :)

People can spout off about other products 'community' and 'support' but VB is in a different class.

I'll leave it there b4 I start gushing :)

Freddie Bingham
08-11-2001, 07:34 PM
It just shows you how do it, you will have to format it how you wish. If you are not going to use the event text than you can remove it from the SELECT portion of the query.

Dave#
08-11-2001, 07:39 PM
Originally posted by freddie
It just shows you how do it, you will have to format it how you wish. If you are not going to use the event text than you can remove it from the SELECT portion of the query.

The formatting was a breeze as log as I escape " :)

It;s exactly as I needed 100% perfect and will save me lots of time every week

In action www.cpfc.org (latest fixtures)

Mike Sullivan
08-11-2001, 07:44 PM
[QUOTE]Originally posted by Dave#
In action www.cpfc.org (latest fixtures)

Dave#
08-11-2001, 07:46 PM
Originally posted by Ed Sullivan
It's linking to the wrong place though :)

http://www.cpfc.org/calendar.php?action=getinfo&eventid=82 gives a 404.

Should be: http://www.cpfc.org/forums/calendar.php?action=getinfo&eventid=82

And make sure that's not a hardcoded sessionhash -- I don't know if you're including vB elements, which would generate a new sessionhash or what.

Fixed that :)

Ed Can you explain the session hash thing please? Should the href be different than calendar.php?s=$session[sessionhash] ?

sysmom
08-11-2001, 08:05 PM
Wow, this can go on a non-vBulletin page, too?

-deb

Mike Sullivan
08-12-2001, 01:36 AM
[QUOTE]Originally posted by Dave#
Ed Can you explain the session hash thing please? Should the href be different than calendar.php?s=$session[sessionhash] ?

boatdesign
08-12-2001, 12:47 PM
Very cool! Thank you, thank you!

One question,

I want to include the event date on my homepage, but when I use $event['eventdate'] I get the date in the format 2001-08-24. How would I either:

1.) Change it from 2001-08-24 to 08-24-2001 or

2.) What I really want to do is to not show the year on my homepage, displaying just 08-24 for the event instead of 2001-08-24.

Thanks again!

Freddie Bingham
08-12-2001, 01:36 PM
Use this query:SELECT DATE_FORMAT(eventdate,'%m-%d') AS eventdate, eventid, subject
FROM calendar_events
WHERE public = 1 AND eventdate >= NOW()
ORDER BY eventdate LIMIT 5

boatdesign
08-12-2001, 02:41 PM
Thanks again.

Now it's in the format I want (just Month-date wihtout a year to shorten it) but this messes up the sorting.

I have one event entered in Feb 2002, and if I leave off the year according to your instructions it is now showing up at the top of the list (2-06 (of 2002) is now coming before 8-15)

Any ideas on how to fix the sorting and still leave off the year from the displayed list?

For that matter, would it be possible to use some kind of array (?) to convert 01 to Jan, 02 to Feb, 03 to Mar, etc... so the date would display as Aug 15 for example?

Thanks again for the original mod which is already fantastic!

Freddie Bingham
08-12-2001, 03:09 PM
<?php

include('./global.php');

$events = $DB_site->query("SELECT DATE_FORMAT(eventdate,'%b %d') AS date, eventid, subject
FROM calendar_events
WHERE public = 1 AND eventdate >= '".vbdate('Y-m-d',time())."'
ORDER BY eventdate LIMIT 5");
if ($DB_site->num_rows($events)) {
echo "Next Five Events:<br>";
while ($event = $DB_site->fetch_array($events)) {
echo "<a href='calendar.php?s=$session[sessionhash]&action=getinfo&eventid=$event[eventid]'>$event[subject]</a><br>";
}
} else {
echo "No Events";
}
?>Refer to $event[date] for the date output in your template.

dkilburn
08-12-2001, 03:21 PM
This is a great hack :-) OK, not to sound dumb, but where exactly do I use this? I am new to PHP so this is a great learning experience!

Do I add the code above to the todaysevents.php file? I'd like to place the events on the top of my VB as a reminder of deadlines for my students. My class homepage (http://www.collegeteacher.org) is set up with SSI. Can I call the script through SSI to include on the homepage as well? I know that converting the whole site to PHP is probably the right answer, but that will have to wait till next semester. School starts tomorrow!

Thanks for your help :D

boatdesign
08-12-2001, 03:45 PM
What I did was to create a new php file called showevents.php with just the code above.

Then on my SSI pages, I include an include statement like:
<!--#include virtual="/forums/showevents.php"-->

And it works like a charm!

xdam
08-13-2001, 05:20 AM
how could i call calander events for a specific user?

boatdesign
08-13-2001, 07:40 PM
An interesting side effect I just noticed is that a visitor to any of the pages on which you've included the list of upcoming events now shows up in the online.php section and counts as a visitor on the forum homepage...

xdam
08-14-2001, 08:42 AM
please please please help me with my question ive been asking it for days

JackG
08-18-2001, 08:46 PM
Oooooooh YEAH It works..displays the events
fim but on top of the 5 events listings I get this error:

Warning: Failed opening './global.php' for inclusion (include_path='') in D:\websites\clubFREESTYLE.com\test.php on line 138


you can see for youself on our test page:

http://www.clubfreestyle.com/test.php

(left side column)

-----------------------
If i change the code to reflect: forum/admin

I get this error:

Warning: Failed opening '/forum/global.php' for inclusion (include_path='') in D:\websites\clubFREESTYLE.com\test.php on line 137



Thanks

JackG
08-18-2001, 09:00 PM
UPDATE:

I removed the : include('./global.php');
call and it works fine with no error

Is this ok to do?

Pyro
08-28-2001, 03:14 PM
Hi everyone,

this hacks just works fine - if, yes if the php file which includes the calendar_hack.php3 is in the vb directory.

I would like to include the hack code like this
<? include ("calendar_hack.php3"); ?> in my index_homepage.php3 file which is NOT in the vb directory.

When I do this from outside that dir, it always give me a Failed opening required './global.php3' (include_path='')...

When I use the absolute path to global.php3 in the calendar_hack.php3 file, it does not find the config.php3...

So, how do I have to include correctly (best would be in absolute paths) that it works for pages from outside the vb directory???

Many thanks in advance!
Markus

Pyro
08-29-2001, 01:51 PM
Ok thanks,

chdir('directory');

before the inclusion is the correct way...

Markus

atease
02-06-2002, 10:44 AM
Originally posted by freddie
<?php

include('./global.php');

$events = $DB_site->query("SELECT event, eventdate, eventid, subject
FROM calendar_events
WHERE public = 1 AND eventdate >= '".vbdate('Y-m-d',time())."'
ORDER BY eventdate LIMIT 5");
if ($DB_site->num_rows($events)) {
echo "Next Five Events:<br>";
while ($event = $DB_site->fetch_array($events)) {
echo "<a href='calendar.php?s=$session[sessionhash]&action=getinfo&eventid=".$event['eventid']."'>".$event['subject']."</a><br>";
}
} else {
echo "No Events";
}
?>It should even be Kier approved in terms of quoted array indices but it may be subject to correction.


tried this but get this error: Fatal error: Failed opening required './admin/config.php' (include_path='.:/usr/local/lib/php') in /home/atease/public_html/forums/global.php on line 72

does anyone know what i might have done wrong?
i'd appreciate it.
thanks

sysmom
03-13-2002, 06:10 AM
Well, I have a completely new (but spectacular) issue with this great little scrap of code that calls out the next 5 events.

First, it works, :)

However, I'm changing things over to a PostNuke front page and content pages for a site, with VB as the workhorse forum and community.

I need the little events script to run in a standard php block for PostNuke. The PostNuke is in a separate mySQL database from the vBulletin.

Now, I did get it to run. BUT, it seems to *clobber* the living daylights out of a couple (but not all) other modules that are used with PostNuke.

So the page loads, the events are listed, but the moment you try to go to one of the affected modules, it starts spitting out:

Warning: Supplied argument is not a valid MySQL result resource

and goes on to give the path of the php file, which I won't bore you with here. There's a few warnings like this. It's really quite spectacular all over the screen. ;)

First, let me say I know enough about php and mySQL to be dangerous. But I follow directions very well!

I have a suspicion that after the events query is made, the rest of the page gets confused about what database it is in. But why this only happens with some modules and not others is a mystery to me.

I might be all wrong.

Whatever is happening, it isn't pretty, and I'd really like to be able to include the events on the front page.

I don't know how to fix it, whether it is what I think it is or not, though. :|

Would someone please explain to me what could be going on, and how to fix it? I can point you to specific files and examples if needed, but I'll bet you vBulletin and php gurus would know what to do in your sleep with your hands tied and your computer off! It seems like some sort of obvious error condition like that to me. :(

Halp Mr. Wizard!

-deb

Broncos
03-16-2002, 06:17 PM
I can get this to work fine if I call the events.php file itself. But when I try to include that file on my front page I get the following:

Warning: Failed opening './global.php' for inclusion (include_path='') in /path/to/my/board/events.php on line 3

Fatal error: Call to a member function on a non-object in /path/to/my/board/events.php on line 5

I tried putting the assolute path in line 3:

include('/path/to/my/board/global.php');

but that simply produces a blank screen?

WebMasterAJ
03-17-2002, 11:02 PM
I just found this, and it is EXACTLY what I'm looking for. When I originally installed the hack, I had less than 5 next events. I then added a lot more dates (about 15 more).

Now, I receive this error:

Warning: Cannot add header information - headers already sent by (output started at /path/username/to/boards/calendarfront.php:3) in /path/username/to/boards/admin/functions.php on line 1581

I named this PHP script calendarfront.php

Thanks for any help!

WebMasterAJ
03-18-2002, 01:19 PM
I did some more trouble shooting with this and found that when I went DIRECTLY to the page that loads the script I get that error. However, if I first go to my message boards, and then go to the page, it works fine.

EX: Go to http://www.finheaven.com/, then http://www.finheaven.com/seasonal/dates.shtml in a new browser window after all other windows are closed

Someone I talked to said that it sounds like a cookie issue, but that's just a guess - i.e. expecting a cookie to exist that does not

However, if you go to the message boards: http://boards.finheaven.com/ and then type the URL in the Address bar it works fine. Strange....

Any ideas?

WebMasterAJ
03-18-2002, 03:08 PM
I found out why the problem was being caused. Thank you for your time.

Daderin
03-18-2002, 06:28 PM
Could you let us know how you solved that problem Webmasta please ? I remember getting the same errors when I was trying something and I gave up after it

Clegg
08-21-2003, 05:13 AM
I am not a programmer or anything cool like that. I am a geek who just knew how to read a SQL DB and get this thing working under vB3

So here is the code: (EDIT - Corrected a major error in the code date setup due to vb3)


$events = $DB_site->query ("SELECT UNIX_TIMESTAMP() AS dateline, dateline_from, eventid, title
FROM event
WHERE calendarid = 1 AND dateline_from > dateline
ORDER BY dateline_from LIMIT 4");


dateline_from is the vb3 variable for the starting date of the event, and am defining the field dateline for the current date and getting a unix timestamp to so the comparison in the where is more reliable ( had some issue with YYYY-DD-MM formats). Then later with a string like this:
$timestring=$event['dateline_from'];
$dateevent=date("M j,Y",$timestring);
I convert the dateline_from into a readable format.


works like a freaking charm :)

roxics
09-25-2003, 08:20 AM
Is there anyway to get this to show up easily on any VB (really a webtemplates) page via an $events tag or something?

Thanks

offlead
01-15-2004, 05:49 PM
Okay, does anyone have the full code for this for vb3, that they could share? I've managed to get, well, something, pulling into the non-forum page, and I have it linking to the calendar, but I'm only getting one event, and the link isn't quite correct (it links to the calendar okay, but not to the event). I'm all confused. :)

filmhobbit
01-29-2004, 02:16 AM
Right so this doesn't work even a little or is just to complex for me to understand. Probably both.

filmhobbit
01-29-2004, 02:37 AM
ah there it goes! kicked in with some tinkering. Nice little script guys! Good work.

krit
01-29-2004, 02:43 AM
Hi guys.

I too would love someone to simply post the php coding they are using for vB3. I presume most are creating a file, say eventlist.php, and calling it into their page via include statements? If someone could post the code in the php file that would be appreciated greatly!

Cheers
Krit

offlead
02-05-2004, 06:18 AM
I actually managed to get this working, eventually, but just discovered that it's showing old events that are already past. Eep! I've checked over the code, and it looks like it should be working correctly, but I'm definitely getting old events.

I checked the sql query in phpmyadmin, and I get the same results. The query is:
SELECT UNIX_TIMESTAMP( ) AS dateline, dateline_from, eventid, title
FROM event
WHERE calendarid = 1 AND dateline_from > dateline
ORDER BY dateline_from
LIMIT 5

and in phpmyadmin when I run this I get the same events as I do in the script. Here are the dateline and dateline_from values from the five events returned:


dateline dateline_from eventid title
1075968522 1074603600 1 Hernando Beach Blast III
1075968522 1074704400 3 HBBIII 2004
1075968522 1077840000 11 Hinkster's Birthday
1075968522 1082246400 12 Michigan NCRS Swap Meet
1075968522 1083283200 7 New England Chapter Event

I can see that the dateline value being returned appears correct...it's the same for each row returned. But event 1 and event 3 were in January, and clearly their dateline_from values are less than the dateline values. So why are they being returned?

*confused* :)

offlead
02-23-2004, 04:43 AM
I still need some help with this. :) I managed to finally get it posting only upcoming events, and not events which have already past. However, now I'm getting the wrong dates displaying on the events. If an event is in the calendar for Feb 30, it displays on the non-vb page as being on Feb 29. All events are dated one day early.

Here's what I currently have.


<?php
chdir("/home/vettehea/public_html/forums");

include('./global.php');

$events = $DB_site->query ("SELECT UNIX_TIMESTAMP( ) AS dateline, dateline_from, eventid, title
FROM event
WHERE calendarid = 1 AND dateline_from > UNIX_TIMESTAMP( )
ORDER BY dateline_from
LIMIT 10");
$vh_upcomingevents = "";
if ($DB_site->num_rows($events)) {
while ($event = $DB_site->fetch_array($events)) {
$timestring=$event['dateline_from'];
$dateevent=date("M j, Y",$timestring);
$vh_upcomingevents .= "$dateevent: <a href=\"/forums/calendar.php?$session[sessionurl]do=getinfo&amp;day=$day&amp;e=$event[eventid]&amp;c=$event[calendarid]\">$event[title]</a><br />";
}
} else {
$vh_upcomingevents .= " -- no events currently listed -- ";
}

?>


I'd greatly appreciate any help clearing up this last issue to this for me.

:)

offlead
02-25-2004, 03:12 PM
I still need some help with this. :) I managed to finally get it posting only upcoming events, and not events which have already past. However, now I'm getting the wrong dates displaying on the events. If an event is in the calendar for Feb 30, it displays on the non-vb page as being on Feb 29. All events are dated one day early.

Here's what I currently have.


<?php
chdir("/home/vettehea/public_html/forums");

include('./global.php');

$events = $DB_site->query ("SELECT UNIX_TIMESTAMP( ) AS dateline, dateline_from, eventid, title
FROM event
WHERE calendarid = 1 AND dateline_from > UNIX_TIMESTAMP( )
ORDER BY dateline_from
LIMIT 10");
$vh_upcomingevents = "";
if ($DB_site->num_rows($events)) {
while ($event = $DB_site->fetch_array($events)) {
$timestring=$event['dateline_from'];
$dateevent=date("M j, Y",$timestring);
$vh_upcomingevents .= "$dateevent: <a href=\"/forums/calendar.php?$session[sessionurl]do=getinfo&amp;day=$day&amp;e=$event[eventid]&amp;c=$event[calendarid]\">$event[title]</a><br />";
}
} else {
$vh_upcomingevents .= " -- no events currently listed -- ";
}

?>


I'd greatly appreciate any help clearing up this last issue to this for me.

:)
*bump*

Anyone? :)

gopherhockey
03-07-2004, 01:08 AM
I still need some help with this. :) I managed to finally get it posting only upcoming events, and not events which have already past. However, now I'm getting the wrong dates displaying on the events. If an event is in the calendar for Feb 30, it displays on the non-vb page as being on Feb 29. All events are dated one day early.

Here's what I currently have.


<?php
chdir("/home/vettehea/public_html/forums");

include('./global.php');

$events = $DB_site->query ("SELECT UNIX_TIMESTAMP( ) AS dateline, dateline_from, eventid, title
FROM event
WHERE calendarid = 1 AND dateline_from > UNIX_TIMESTAMP( )
ORDER BY dateline_from
LIMIT 10");
$vh_upcomingevents = "";
if ($DB_site->num_rows($events)) {
while ($event = $DB_site->fetch_array($events)) {
$timestring=$event['dateline_from'];
$dateevent=date("M j, Y",$timestring);
$vh_upcomingevents .= "$dateevent: <a href=\"/forums/calendar.php?$session[sessionurl]do=getinfo&amp;day=$day&amp;e=$event[eventid]&amp;c=$event[calendarid]\">$event[title]</a><br />";
}
} else {
$vh_upcomingevents .= " -- no events currently listed -- ";
}

?>


I'd greatly appreciate any help clearing up this last issue to this for me.

:)

I used your code and it works for me, plus the dates are all just fine. It isn't picking up all the events, however.. don't know why some are just missing. Could it be a timezone issue with your server maybe? (just grasping for straws) - maybe you could compensate by adding or subtracting one day... ?

One thing I have a problem with is how far out its reaching. It gets the next X number of events, regardless of the dates. I'd like to only display X number of events X days ahead. Currently my test board has 2 events next week and one Oct. of this year and its showing that one.... thats a bit too far out to be reminding people I think ;)

magmaink
05-22-2004, 07:44 PM
Anyone Get any updates on this.. V3 is 1 day off still??

magmaink
05-26-2004, 12:03 AM
anyone?

magmaink
05-31-2004, 01:36 AM
need this bad....somebody please respond!

magmaink
06-06-2004, 02:48 PM
no love?

user 1-2-3
06-14-2004, 12:52 AM
How can I make the same thing for 3.0.1? I need to place events from calendar into the home page.

magmaink
06-22-2004, 01:34 PM
Alright dammit....I am completely clueless in regards to php but I still managed to figure this one out. on the timestring code......you have to add "+= 86400" in order to compensate for the missing 24 hours.....Here's my code:


$events = $DB_site->query ("SELECT UNIX_TIMESTAMP( ) AS dateline, dateline_from, eventid, title
FROM event
WHERE calendarid = 1 AND dateline_from > UNIX_TIMESTAMP( )
ORDER BY dateline_from
LIMIT 10");

if ($DB_site->num_rows($events)) {
while ($event = $DB_site->fetch_array($events)) {
$timestring=$event['dateline_from'] += 86400;
$dateevent=date("m-d-Y",$timestring);
echo "$dateevent <a href=\"/vb/calendar.php?$session[sessionurl]do=getinfo&amp;day=$day&amp;e=$event[eventid]&amp;c=$event[calendarid]\">$event[title]</a><br />";
}
} else {
echo $vh_upcomingevents .= " -- no events currently listed -- ";
}

traderx
11-12-2004, 05:43 AM
Alright dammit....I am completely clueless in regards to php but I still managed to figure this one out. on the timestring code......you have to add "+= 86400" in order to compensate for the missing 24 hours.....Here's my code:


$events = $DB_site->query ("SELECT UNIX_TIMESTAMP( ) AS dateline, dateline_from, eventid, title
FROM event
WHERE calendarid = 1 AND dateline_from > UNIX_TIMESTAMP( )
ORDER BY dateline_from
LIMIT 10");

if ($DB_site->num_rows($events)) {
while ($event = $DB_site->fetch_array($events)) {
$timestring=$event['dateline_from'] += 86400;
$dateevent=date("m-d-Y",$timestring);
echo "$dateevent <a href=\"/vb/calendar.php?$session[sessionurl]do=getinfo&amp;day=$day&amp;e=$event[eventid]&amp;c=$event[calendarid]\">$event[title]</a><br />";
}
} else {
echo $vh_upcomingevents .= " -- no events currently listed -- ";
}



Will the above work for 3.0.3? I am also looking for something to get the last X threads and polls.... any one?

Coll

Rebecca217
11-17-2004, 02:39 PM
I'm using 3.0.3 also, and needed this same thing. The above code didn't work for me as-is, so I tweaked it a bit until I got what I needed. I don't claim to be a programmer, so use this at your own risk. ;)


Alter this to point to your own Vb installation, then paste it above everything else in your page. (Before the <html> tag, etc.)

<?php

// Require global.php

chdir ('forums');

require ("global.php");

?>



Paste this where you'd like the events to appear. Alter the $day format to your preferences. Also, the LIMIT variable can be changed to however many entries you'd like listed.


<?php

print "<ul>";

$events = $DB_site->query ("SELECT UNIX_TIMESTAMP( ) AS dateline, dateline_from, eventid, title

FROM event

WHERE calendarid = 1 AND dateline_from > UNIX_TIMESTAMP( )

ORDER BY dateline_from

LIMIT 3");

if ($DB_site->num_rows($events)) {

while ($event = $DB_site->fetch_array($events)) {

$timestring=$event['dateline_from'] += 86400;

$dateevent=date("F d, Y",$timestring);

$day=date("Y-m-d",$timestring);

echo "<LI><B>$dateevent</b> - <a href="/\"/forums/calendar.php?$session[sessionurl]do=getinfo&amp;day=$day&amp;e=$event[eventid]&amp;c=1\">$event[title]</a></li>";

}

} else {

echo $vh_upcomingevents .= " -- no events currently listed -- ";

}

print '<LI><B><a href="./forums/calendar.php">view other events</a> &raquo;</b></li>';

print "</ul>";

?>



Hope this helps!

Rebecca

traderx
11-19-2004, 06:03 AM
I will give that a try very soon.... Thanks

I went to your site (nice) and saw that you are pulling the lastest threads also, could you point me to the post about that or pm it to me pls

Thanks
Coll

majorxp
09-15-2005, 05:48 PM
I got it to work for me using 3.5...

Here is the code I used. I hope this helps.

..disregard...I found a bug and I'm pulling this till I get it to work or I give up..sorry...

/...also sorry for bumping an old thread.../ :disappointed:

...edit...

the code works fine for non-repeating events. i have no clue how to get a list of upcomming events for the next week to include them.........

/sigh