Goto Admincp->vBullietin CMS->Widgets->Create New Widget
Choose PHP Direct Execution as Widget's Type
Place a Title. eg Upcoming Events. Keep it short as this is what will appear as title on your pages.
Click Save
Click Configure on the right of the new created widget.
Remove the default code that appears. Be sure to not leave behind even a single letter.
Copy and Paste the code that you can find below.
Leave the template name as is (vbcms_widget_execphp_page)
Click Save
Goto Admincp->vBullietin CMS->Layout Manager
Click Go on the Default Layout
Add the Widget to your Layout
Click Save
That's all !!
PHP Code
PHP Code:
ob_start();
// %d
$show_count = 5;
$query = sprintf("SELECT * FROM ".TABLE_PREFIX."event WHERE visible = 1 AND (dateline_from > '%d' || ( dateline_from > '%d' AND dateline_to < '%d' )) ORDER BY dateline_from ASC LIMIT %d",TIMENOW,TIMENOW,TIMENOW,$show_count);
I have the problem described that if a one day event is added to calendar for 15th Jan, it shows up in this widget as 14th Jan. I think others had this problem, but I don't see a solution. Please is there a fix for this or an edit I can do to the code? Thanks, Claudia
I have the problem described that if a one day event is added to calendar for 15th Jan, it shows up in this widget as 14th Jan. I think others had this problem, but I don't see a solution. Please is there a fix for this or an edit I can do to the code? Thanks, Claudia
Same issue here. I removed the widget until I can find or figure out a solution.
Widget is working fine now. We did not need to make any mods to the widget itself.
Our problem was that the date the upcoming events appeared to be offset by one day.
From doing a few tests this was due to the server itself being on the wrong timezone for us. We rang the host and simply asked them to update the time and timezone on the server to our actual timezone, which was 6 hours off.
The date/times for the events are stored as unix timestamps and these get converted using the php date function. As such they will be converted against the actual server time, rather than any setting you might have in vBulletin.
It won't work if the time isn't correct, I can't use this unfortunately as it off a day. Needs to take the time from my settings, not the shared host server.
In the widget code you code force the time offset by adding or subtracting 3600 for every hour you need to offset to each of the unix timestamps. This should produce the same result, and easy enough to add in. Simply change the following:
if($event['dateline_to'] == 0 )
{
$format = sprintf("On %s",date('jS M Y',$event['dateline_from']));
} else {
$format = sprintf("From %s to %s",date('jS M Y',$event['dateline_from']),date('jS M Y',$event['dateline_to']));
}
to:
$tz_offset = 3600;
if($event['dateline_to'] == 0 )
{
$format = sprintf("On %s",date('jS M Y',($event['dateline_from']+$tz_offset)));
} else {
$format = sprintf("From %s to %s",date('jS M Y',($event['dateline_from']+$tz_offset)),date('jS M Y',($event['dateline_to']+$tz_offset)));
}
It would be nice to have a Upcoming Events widget that uses UserGroup permissions and posts calendar information the same way as in the "Whats Going On?"section of the forum.