Where is the widget code for the calendar than you have on the vBulletin 4 homepage? I'd love to add it to mine. Is it available?
vBulletin calendar on homepage
Collapse
X
-
Have you read the documentation? The process for creating new widgets is explained. http://www.vbulletin.com/forum/content.php?151
The CMS release calendar? admincp > vbulletin cms> widgets > create new widget , select CMS Published Calendar. Then admincp > vbulletin cms> layouts and drag it onto whatever layout you are using.Please- I'm not tech support. Don't send your problem reports to me unless I've asked you to. -
Comment
-
If you're willing to live with a simple list of events, this will work. A couple of comments:
- This is unsupported. Use at your own risk.
- It assumes that the calendar is public. This bypasses the permissions checking.
- This checks from the last 24 hours and some number of days (14 by default) into the future. You can chance "$daysforward" to a different value to get more or fewer.
- I would set the widget configuration cache time to 0. The included code caches for a time of one hour.
- $calendarid determines which calendar you get.Change that to whichever calendar you want.
- $cache_ttl determines how often the data is updated. If you want changes to be immediate feel free to change it, BUT NOT TO zero! Keep it at least five (five minutes between updates.
- Where the 'output .=' code is, if you know html, you could make the output a bit fancier if you like.
To use this
- in admincp > vbulletin cms > widget manager create a PHP Direct Execution
- in admincp > vbulletin cms > widget manager configure it by pasting in the code below, and set a cache time of zero.
- in admincp > vbulletin cms > layout manager drop it onto your layout.
PHP Code:$cache_ttl = 60;
$daysforward = 14;
$calendarid = 1;
$cachekey = 'cmswidget_calendar_' . $this->widget->getId() ;
$events = vB_Cache::instance()->read($cachekey, false, true);
$output = '';
if (!$events)
{
$start = TIMENOW - 86400;
$end = TIMENOW + ($daysforward * 86400);
$sql = "SELECT * FROM " . TABLE_PREFIX . "event WHERE
calendarid = $calendarid AND dateline BETWEEN $start AND $end ORDER BY dateline";
$eventlist = vB::$db->query_read($sql);
if ($eventlist)
{
while($event = vB::$db->fetch_array($eventlist))
{
$events[] = $event;
}
}
vB_Cache::instance()->write($cachekey,
$events, $cache_ttl );
}
foreach ($events as $event)
{
$output .= "<a href=\"" . 'calendar.php?' . $vbulletin->session->vars['sessionurl'] .
"do=getinfo&e=" . $event['eventid']. "\">" . htmlspecialchars_uni($event['title']) .
' ' . vbdate(vB::$vbulletin->options['dateformat'], $event['dateline'])
."</a><br />\n";
}
Please- I'm not tech support. Don't send your problem reports to me unless I've asked you to.Comment
-
I would really like to have something like this to work.
Ayway, I tried on a test site (localhost) and if the calender is emtyp I get some sort of error message, then I added to events (one day events) one a mont from now and one some years from now. they both showed up in the widget but had todays date next to them. ??
I hope this will be a standard thing soon. We have the opportunity to show upcoming events in the Whats going on area on forum home page, but having this in a widget in the cms is really needed.
/AndersAnders Pettersson
Don't send me requests by PM to email you the Swedish language file that I have done. My translation is only available here at vbulletin.com to licensed users.
If you want updates on when a new version of the Swedish language packs (forum & suite) are available, subscribe to this discussion.
Don't PM me for support on how to install language files etc. please post in the appropriate forum, that will most likely give you help quicker.Comment
-
above php code does not work, gives error on line 25 code. Really would love the wgo upcoming events for cms page. the one everyone keeps linking to .org does not work as it does not show the events on the current day they are running.Comment
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Comment