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);
Hi
Firstly, I love the widget and so far it (kind of) works.
The small problem I have is that it does not seem to adjust for my Default Time Zone Offset, which is GMT + 10. So the homepage says an event is on the 10th and the calendar says it is on the 11th depending on the time of day you visit the site.
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/rat10541/public_html/forum2010/includes/class_core.php(4033) : eval()'d code on line 14
I'm using a hybrid of NicForce's code (formatted to provide the date format that I want), but I noticed that if you are not logged on, the dates are 24 hours ahead (so a July 3rd event will show on July 4), but if you log on, the dates are correct.
here is my code, but I still can figure this out. I don't see anything that tells me to be logged in or not.
ob_start();
// %d
$show_count = 15;
$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);
Not that I really understand anything of this, but the major difference between the original code and NicForce's is that the code adds +1 to the date from and the date to. It seems you do not make a time adjustment like that, if I look over your code (not that I understand the coding).
I set it at +1 although my GMT = +10. Maybe the +1 refers to a date (a day) and not an hour.
I also found that when you use an event which covers more than one day, you might have to be creative with the begin and end dates.
I tried this widget using the default code at Post #1. Setting an event say from 2 April 2010 to 4 April 2010; when 2 April comes (ie today) the whole event no longer appears.
I tried this widget using the default code at Post #1. Setting an event say from 2 April 2010 to 4 April 2010; when 2 April comes (ie today) the whole event no longer appears.