View Full Version : vB3 calendar showing on non vb page
Zlaxzzor
09-27-2003, 11:28 AM
Ok... I would really need a hack for the vB3 calendar. What I want it to do is to show for example the 5 comming happenings on my site (not on vb). Since you can have multiple different calendars in vB3 it would be really great if someone also could fix so the script only reads from one of the calendars.
Gary King
09-27-2003, 11:12 PM
Ok... I would really need a hack for the vB3 calendar. What I want it to do is to show for example the 5 comming happenings on my site (not on vb). Since you can have multiple different calendars in vB3 it would be really great if someone also could fix so the script only reads from one of the calendars.
no vb3 hacks allowed yet, I believe
insanctus
09-27-2003, 11:37 PM
No vb3 hacks untill rc, it is posted.
Zlaxzzor
09-28-2003, 12:29 AM
oh, that's a pity :|
Clegg
10-08-2003, 03:05 AM
Hey man I gotcha covered
this is NOT a hack as many people seem to think you are simply reading from the MYSQL DB data that VB3 has put there... So chill you damn nazi's ;)
www.midwestlan.com almost everything on that site is tied to vb3 and not one VB3 file has been modified, all just custom PHP scripts and SQL calls. in the top right hand corner you can see a listing of coming events. heres my code for it:
<?php
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() AND userid = 1
ORDER BY dateline_from LIMIT 4");
if ($DB_site->num_rows($events)) {
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"#353535\">
<tr>
<td COLSPAN=2 align=\"center\" width=\"100%\" bgcolor=\"#550000\"><font class=\"heading\" face=\"verdana, arial, helvetica\" size=\"1\" color=\"FFFFFF\"><b><a href='http://www.midwestlan.com/forums/calendar.php?c=1&do=displaymonth'>Upcoming MWL Events</a></b></font></td>
</tr>
";
while ($event = $DB_site->fetch_array($events)) {
$timestring=$event['dateline_from'];
$dateevent=date("M j,Y",$timestring);
echo "
<tr>
<td align=\"center\" width=\"80\" bgcolor=\"101010\"><font face=\"verdana, arial, helvetica\" size=\"1\" color=\"888888\">$dateevent</font></td>
<td align=\"center\" bgcolor=\"101010\" width=\"183\"><font face=\"verdana, arial, helvetica\" size=\"1\"><b><a href='http://www.midwestlan.com/forums/calendar.php?do=getinfo&e=$event[eventid]&c=1'>$event[title]</a></b></font></td>
</tr>
<tr>
<td colspan=\"2\" bgcolor=\"666666\"></td>
</tr>
";
}
//}
} else {
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"#353535\">
<tr>
<td COLSPAN=2 align=\"center\" width=\"100%\" bgcolor=\"#550000\"><font class=\"heading\" face=\"verdana, arial, helvetica\" size=\"1\" color=\"FFFFFF\"><b><a href='http://www.midwestlan.com/forums/calendar.php?c=1&do=displaymonth'>Upcoming MWL Events</a></b></font></td>
</tr>
<tr>
<td COLSPAN=2 align=\"center\" width=\"100%\" bgcolor=\"#000000\"><font face=\"verdana, arial, helvetica\" size=\"1\" color=\"FFFFFF\"><b>No Events Upcoming Currently</b></font></td>
</tr>
<tr>
<td colspan=\"2\" bgcolor=\"666666\"></td>
</tr> ";
}
echo "</table>";
?>
Ive modified the events table in the SQL DB to add a few fields since I have a registration system I have integrated to it so that vb's calendar shows events that are coming up for other lans and my own. Lets break this down:
$events = $DB_site->query ("SELECT UNIX_TIMESTAMP() AS dateline, dateline_from, eventid, title
FROM event
WHERE calendarid = 1 AND dateline_from > UNIX_TIMESTAMP() AND userid = 1
ORDER BY dateline_from LIMIT 4");
What this does is reads the eventid, title, dateline_from, from teh data base. and then validates its a public item (calendar id = 1) and that it happens before the current time. This also limits the ones that are displayed publicly to my user ID only. ( user ID 1) Because now the registration system posts public events, I dont want them showing. It then sorts them by the dateline_from so the soonest is listed first, and it limits that to 4 entries.
if ($DB_site->num_rows($events)) {
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"#353535\">
<tr>
<td COLSPAN=2 align=\"center\" width=\"100%\" bgcolor=\"#550000\"><font class=\"heading\" face=\"verdana, arial, helvetica\" size=\"1\" color=\"FFFFFF\"><b><a href='http://www.midwestlan.com/forums/calendar.php?c=1&do=displaymonth'>Upcoming MWL Events</a></b></font></td>
</tr>
";
while ($event = $DB_site->fetch_array($events)) {
$timestring=$event['dateline_from'];
$dateevent=date("M j,Y",$timestring);
echo "
<tr>
<td align=\"center\" width=\"80\" bgcolor=\"101010\"><font face=\"verdana, arial, helvetica\" size=\"1\" color=\"888888\">$dateevent</font></td>
<td align=\"center\" bgcolor=\"101010\" width=\"183\"><font face=\"verdana, arial, helvetica\" size=\"1\"><b><a href='http://www.midwestlan.com/forums/calendar.php?do=getinfo&e=$event[eventid]&c=1'>$event[title]</a></b></font></td>
</tr>
<tr>
<td colspan=\"2\" bgcolor=\"666666\"></td>
</tr>
";
}
This above essentially diplays the header and then all teh events, I am prettys ure you can make out what its doing.
} else {
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"1\" bordercolor=\"#353535\">
<tr>
<td COLSPAN=2 align=\"center\" width=\"100%\" bgcolor=\"#550000\"><font class=\"heading\" face=\"verdana, arial, helvetica\" size=\"1\" color=\"FFFFFF\"><b><a href='http://www.midwestlan.com/forums/calendar.php?c=1&do=displaymonth'>Upcoming MWL Events</a></b></font></td>
</tr>
<tr>
<td COLSPAN=2 align=\"center\" width=\"100%\" bgcolor=\"#000000\"><font face=\"verdana, arial, helvetica\" size=\"1\" color=\"FFFFFF\"><b>No Events Upcoming Currently</b></font></td>
</tr>
<tr>
<td colspan=\"2\" bgcolor=\"666666\"></td>
</tr> ";
}
echo "</table>";
and if there isnt any items to display it still shows the header and "No Events".
Works like a charm with Vb3. Enjoy!
Now all I need to do is find out how to use the parse bbcode function in vb3 for my site news... theres no formatting that I can access for post data like I used to be able to before in vb2... that was the whole reason I came snooping today :)
We have a few scripts that get latest posts etc that get written to a js file for including on non-vb pages. After upgrading from 2 to latest 3 these all work except for the one accessing the calendar.
The php routine we have always used is as follows, then the error we get. Presume the calendar is held differently in vb3 - Any help appreciated.
require("includes/config.php");
$num_active = 20;
$num_chars = 75;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$fp = fopen("news/events10.js", "w");
@flock($fp, 2);
$today = date("Y-m-d",time());
print ("$today<br>");
$querylatest="SELECT event, DATE_FORMAT(eventdate,'%a %d %b') AS date,
eventdate, eventid, subject
FROM calendar_events WHERE (public = 1 AND eventdate>='$today') ORDER BY eventdate LIMIT $num_active";
echo $querylatest;
$resultlatest = mysql_query($querylatest,$db);
while ($event = mysql_fetch_array($resultlatest)) {
$eventid = $event[eventid];
$eventtitle = addslashes($event[subject]);
$eventdate = $event[date];
print ("<b>$eventid $eventtitle $eventdate</b><br>");
fputs($fp, "document.write(\"<a href='http://www.southportforums.com/forums/calendar.php?action=getinfo&eventid=$eventid'>$eventtitle</a> $eventdate<br>\");\n");
}
@fclose($fp);
print ("<br><b><u>Events Have been updated - Thank You</u></b><br><br>");
Causes error....
2004-09-04
SELECT event, DATE_FORMAT(eventdate,'%a %d %b') AS date, eventdate, eventid, subject FROM calendar_events WHERE (public = 1 AND eventdate>='2004-09-04') ORDER BY eventdate LIMIT 20
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
smdani
02-26-2005, 05:24 PM
Incredible Clegg!! Thaks a lot for share your code.
May I made you a question?
How do you do to show last posts at your main page? I made a script that obtains last posts and prints out the texts, but it shows unparsed texts withs BBCODE TAGS and so...
May you help me?
Thanks in advance
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.