PDA

View Full Version : vBulletin CMS Widgets - [WIDGET] Upcoming Events


cory_booth
02-19-2010, 10:00 PM
Another upcoming events widget...
I am really waiting for someone to kickout an integrated calendar/events widget...
But until then, I am using this PHP widget for my events. I saw a few others on here, but they were not quite what I was looking for...

Feel free to use/hack/slash this code for your own use...

Navigate to AdminCP -> CMS -> Widgets.
Create a PHP Type Widget and paste the below code.


ob_start();
global $db,$vbulletin;
$calendarid="1";
$per_page = "10";
//################################################
$d=date("d");
$m=date("m");
$y=date("y");
$sdate = mktime(0, 0, 0, date("$m"), date("$d"), date("$y"));
$edate = mktime(0, 0, 0, date("$m"), date("31"), date("$y"));
$and=" and dateline_from > '".$sdate."'";

$getevents=$db->query_read("SELECT eventid, title, dateline_from from " . TABLE_PREFIX . "event WHERE calendarid='".$calendarid."' $and order by dateline_from ASC LIMIT $per_page");
$count=0;
if(!$db->num_rows($getevents))
{
}
else
{
WHILE ($events=$db->fetch_array($getevents))
{
$dtitle=$events['title'];
$did=$events['eventid'];
$date = vbdate('m-d-y
',$events['dateline_from'], false,true,false,true);
if ($count = 2){$class="alt2";}else {$class="alt1";}
$year=date("Y");
$pagetitle = $f;
$pagetitle .= " ";
$pagetitle.=$year;
$eventbits .="<tr><td nowrap class=''><strong>".$date.":</strong></td><td width='100%' class=''><a href='calendar.php?do=getinfo&e=$did&c=".$calendarid."'>".$dtitle."</a></td></tr>";
$count++;
}
}
echo "<table align='center' width='100%'>";
echo $eventbits;
echo "</table>";
$db->free_result($getevents);
unset($events);
$output=ob_get_contents();
ob_end_clean();

Bouncer222
02-20-2010, 05:48 PM
Is it possible to use this with vbadvanced as a module?

cory_booth
02-20-2010, 06:02 PM
Most likey, but unfortunately I am not using VBadvanced...
If I remember right, you could load php files as modules.

So take the code, drop the first line ob_start and the last two lines...
Save as a php file and then try loading as a module...

SuperGLS
03-15-2010, 02:42 AM
Gonna try this and see how it works. Thanks!

4thstar
03-19-2010, 11:15 PM
Thankyou this works well, i have one small issue though that you may be able to help with please.

this displays upcoming events but it does not show an event for the day itself, if you have an event on the 20th and it is the 20th it wont show that event, for us the events are on in the evening so during that day we would still like to show it as being an upcoming event,

i edited this bit from
$and=" and dateline_from > '".$sdate."'"

to
$and=" and dateline_from >= '".$sdate."'"


thankyou
Kind Regards
Carl

NashChristian
04-27-2010, 08:43 AM
Thanks!

NashChristian
04-30-2010, 07:13 PM
This displays upcoming events but it does not show an event for the day itself, if you have an event on the 20th and it is the 20th it wont show that event, for us the events are on in the evening so during that day we would still like to show it as being an upcoming event,

i edited this bit from
$and=" and dateline_from > '".$sdate."'"

to
$and=" and dateline_from >= '".$sdate."'"


Hello,

I implemented this modification, as I too want to post events from the current day as well as future dates. I'm having one problem with this, for some reason, though it will list events that are occuring TODAY, it displays TOMORROW's date next to it. Does anyone know how I can fix this?

Here are a couple screen shots (look at the top listing on the widget):

http://nashvillechristian.com/images/support/vb_calendar_widget_error_1.jpg

http://nashvillechristian.com/images/support/vb_calendar_widget_error_2.jpg

The dates are correct for every day's events except TODAY's. I need to find a solution for this. Any help would be appreciated.

Thanks!
:D Jeff

HobbesGTS
05-01-2010, 02:08 AM
Is there anyway to modify this code to get it to display a custom field as well?

NashChristian
05-01-2010, 04:20 AM
Now I'm confused! Ok, I couldn't figure out how to get yesterdays events (04-30-10) to display with yesterday's date (they showed 05-01-10), SO I reverted to Cory's original code (without the '>=' mod), the results have me scrathing my head.

I cleared my CMS cache and tested this using a couple different browsers, here's what I found (the top two events listed are actually 04-30-10 events):

http://nashvillechristian.com/images/support/vb_calendar_widget_error_3.jpg

NOTHING CHANGED. Which confuses me for two reasons. The first, is since I'm running the original code without the slightest change, why am I the only one claiming to have a problem with this. Second, it was my understanding that events for TODAY would NOT show up with this widget, which is why 4thstar added the '>=' mod.

Is anyone else experiencing similar difficulties?

Another thing that has me scratching my head, is now that the clock reads 12:20 AM, and the day has effectively changed to 05-01-10 (first day of the month) the events listed for TODAY display the correct date (05-01-10) in the widget.

http://nashvillechristian.com/images/support/vb_calendar_widget_error_4.jpg

Is this just some sort of "end-of-the-month bug"? Has anyone else noticed this or come up with some sort of work-around?

Help me out here people, I'm confused.

Thanks!
:confused: Jeff

NashChristian
05-01-2010, 04:48 AM
Actually, upon further investigation, I see that I'm having the same problem on SEVERAL of my upcoming event posts with this widget. Here are two screen shots that illustrate this problem (compare the event dates with those displayed in the widget above):

http://nashvillechristian.com/images/support/vb_calendar_widget_error_5.jpg

http://nashvillechristian.com/images/support/vb_calendar_widget_error_6.jpg

This isn't happening on EVERY event, however it is happening on close to 50% of them! I don't think the date syntax works in this code. I appreciate what it is trying to accomplish, instead of listing it in long form like the other mod out there, I really prefer the short format, but I don't think it works right. When the date is off, it is always off by exactly 1 day.

Is anyone using this with a site that posts a lot of events, and can you provide a link to your site so I can compare the widget dates to the actual calendar event dates? I'd be curious to see how this is working for other people.

What a shame! I really like this mod, and don't want to use the long form date range display.

Bummer!
:( Jeff

NashChristian
05-01-2010, 05:38 AM
Alright, at least I'm not going crazy. I did some research at our neighboring events widget (https://vborg.vbsupport.ru/showthread.php?t=231365) mod, and found that they have encounterd the exact same problem, with a solution outlined here (https://vborg.vbsupport.ru/showpost.php?p=1944388&postcount=33).

My GMT is -6, so whenever an event is scheduled to begin at 6pm or later, it displays the date for the following day.

Now, I just need to figure out how to apply this same solution to this mod.

At least there is hope.
:D Jeff

wIrEs
05-01-2010, 07:06 AM
how to display something like this ?
Today at 3:00 PM EST + Event Title
and
Tomorow at 7:00 PM EST + Event Title
and
05-03-10 at 4:00 PM EST + Event Title

Thanks !

unfv
05-03-2010, 01:49 AM
Hi, is there any chance to show birthdays on this widget?

Thanks!

SuperGLS
05-04-2010, 04:44 PM
Is there any way to set how far in advance it grabs events? Like an event in August? Is that too far away?

Also, I wish the colon had a space on the RIGHT instead of the LEFT. Any ideas?

Zweeper
07-23-2010, 03:51 PM
it would be an awesome widget if it would also represent the birthdays of the members.

rabidkevin
07-23-2010, 04:24 PM
Alright, at least I'm not going crazy. I did some research at our neighboring events widget (https://vborg.vbsupport.ru/showthread.php?t=231365) mod, and found that they have encounterd the exact same problem, with a solution outlined here (https://vborg.vbsupport.ru/showpost.php?p=1944388&postcount=33).

My GMT is -6, so whenever an event is scheduled to begin at 6pm or later, it displays the date for the following day.

Now, I just need to figure out how to apply this same solution to this mod.

At least there is hope.
:D Jeff

Did you ever figure it out? I'm stuck at the same place as you. And everyone else please post on vbulletin.com and request this as a default widget of vbulletin... http://www.vbulletin.com/forum/showthread.php?358039-Upcoming-Events-CMS-Widget

NashChristian
07-23-2010, 07:44 PM
Did you ever figure it out? I'm stuck at the same place as you. And everyone else please post on vbulletin.com and request this as a default widget of vbulletin... http://www.vbulletin.com/forum/showthread.php?358039-Upcoming-Events-CMS-Widget

I went with the other widget, and modified their code a bit to display as I wanted. I couldn't make this code work for me.

Zweeper
08-01-2010, 12:51 PM
Would be nice if it would look like the one in the attachment.

1. a small calender on the top to see the actual month.

2. then, a row with today's birthdays, if there are birthdays.

3. last but not least, a new row with upcoming events of the next xx days.

Maybe I am not alone with this Idea. Unfortunately I cant code this on my own.
Just to give some useful critic.

imported_pmay68
08-01-2010, 05:11 PM
Would be nice if it would look like the one in the attachment.





1. a small calender on the top to see the actual month.

2. then, a row with today's birthdays, if there are birthdays.

3. last but not least, a new row with upcoming events of the next xx days.



Maybe I am not alone with this Idea. Unfortunately I cant code this on my own.
Just to give some useful critic.

Yeah I really like that one as well..

NashChristian
10-05-2010, 04:33 AM
VOTE NOW! (http://tracker.vbulletin.com/browse/VBIV-7656)

vB has been taking their sweet time developing a corporate solution for this Calendar Widget. It has been logged in Jira, but there have only been TWO votes so far and it appears to have been deprioritized.

Please log into Jira and VOTE FOR THIS! It will only take you a minute: http://tracker.vbulletin.com/browse/VBIV-7656

A number of customer have asked for a calendar widget that will access the current site calendar. That is distinct from the current cms calendar widget that displays dates on which articles have been published. Wayne also feels this should get a high priority.

VOTE NOW! (http://tracker.vbulletin.com/browse/VBIV-7656)

Lexor
10-16-2010, 05:39 PM
I installed the widget on 4.0.7
But when i adde an area in my cms and want to choose it i became an error message like this:

Call to undefined function vbgmdate() in /www/htdocs/XXX/XXXX/packages/vbcms/widget/execphp.php(194) : eval()'d code on line 43

Can you help ?

TCB
02-16-2011, 12:55 PM
Looks and works great. Thanks :D

Eq4bits
03-26-2011, 06:03 AM
Alright, at least I'm not going crazy. I did some research at our neighboring events widget (https://vborg.vbsupport.ru/showthread.php?t=231365) mod, and found that they have encounterd the exact same problem, with a solution outlined here (https://vborg.vbsupport.ru/showpost.php?p=1944388&postcount=33).

My GMT is -6, so whenever an event is scheduled to begin at 6pm or later, it displays the date for the following day.

Now, I just need to figure out how to apply this same solution to this mod.

At least there is hope.
:D Jeff

I went with the other code as well, set the GMT offset to match my site's 'time'.
Had to laugh tho when I went to check to see if it was displaying right.
Display for 'today' was perfect... but April 1st events showed as being
On 32th Mar 2011
Not sure if that's an intentional 'funny' or something weird because March has 31 days... and I don't have have any events for the 29th, 30th or 31st. the wording is a bit 'fonky' for 2nd displaying as '2th' and 3rd displaying as '3th'. Also only 1 event per date is showing when I know at least one has 2 events scheduled

Eq4bits
06-24-2011, 03:58 PM
Also, I wish the colon had a space on the RIGHT instead of the LEFT. Any ideas?
I was able to add a space *after* the colon (but unable to remove the space to the left by changing
THIS$eventbits .="<tr><td nowrap class=''><strong>".$date.":</align></td><td width='100%' class=''><a href='calendar.php?do=getinfo&e=$did&c=".$calendarid."'>".$dtitle."</a></td></tr>";
TO THIS$eventbits .="<tr><td nowrap class=''><strong>".$date.":</strong></td><td width='100%' class=''>&npsb;<a href='calendar.php?do=getinfo&e=$did&c=".$calendarid."'>".$dtitle."</a></td></tr>";

Eq4bits
06-25-2011, 12:54 AM
I finally got mine to pull the 'current' date & it's events

FIND:
ob_start();
global $db,$vbulletin;
$calendarid="1";
$per_page = "10";CHANGE TO:
ob_start();
global $db,$vbulletin;
$mydate = mktime(0, 0, 0, date("m"), date("d")-1, date("Y"));
$calendarid="1";
$per_page = "10";FIND:
$getevents=$db->query_read("SELECT eventid, title, dateline_from from " . TABLE_PREFIX . "event WHERE calendarid='".$calendarid."' $and order by dateline_from ASC LIMIT $per_page");CHANGE TO:
$getevents=$db->query_read("SELECT * FROM ".TABLE_PREFIX."event WHERE calendarid='".$calendarid."' AND visible= '1' AND (dateline_from >= '$mydate' || ( dateline_from >= '$mydate' AND dateline_to <= '$mydate' )) ORDER BY dateline_from ASC LIMIT $per_page");

Onkeltyson
06-01-2012, 05:28 PM
Thanks for that ;)

ReBe
08-04-2012, 11:04 AM
I have some recurring entrys, but in the widget only the first from the recurring entrys are shown. Is there a solution for it?

barnsi
08-08-2012, 01:00 PM
changed to $date = vbdate('j. F Y

vor dem "j." muss das Hochkomma stehen, wird hier leider nicht richtig dargestellt.
Das ergibt dann die Anzeige: "9. August 2012" statt "08.09.12"

Arrogant-One
08-09-2012, 08:01 AM
Create a PHP Type Widget and paste the below code.

Hi Cory.

How do I do this exactly? I am a bit of a novice at vB but have learned some stuff. Editting templates is a breeze. Is this like that?

What do you mean by 'Create a PHP Type Widget'

otterag
08-17-2012, 08:11 PM
The calendar im trying to show events for is almost all recurring events and this mod does not show any of them.

Is there a way to pull those for the dates that they actually occur on with out having to redo the entire calendar day by day?

here is a screen shot of the mod on the left and the calendar on the right.

http://armadagames.com/forums/images/background/vB_events_calendar.jpg

4thstar
01-21-2013, 09:42 PM
Hello all.
I hope you dont mind me asking here, i wanted to create an rss feed for my events, i dont know php so its all trial and error for me..

I have edited the code as below which creates afilename.rss, when this file is called it shows an rss feed..

i had issues with some strange characters breaking the page but things seem ok..

I currently have this on my index page as a widget, it cant stay there as it will create to much server work.

Question...

can this be turned into a php file to run as a sheduled task? If so how?

many thanks in advance.

Carl

ob_start();
global $db,$vbulletin;
$calendarid="1";
$per_page = "60";
//################################################
$d=date("d");
$m=date("m");
$y=date("y");
$sdate = mktime(0, 0, 0, date("$m"), date("$d"), date("$y"));
$edate = mktime(0, 0, 0, date("$m"), date("31"), date("$y"));
$and=" and dateline_from >= '".$sdate."'";

$getevents=$db->query_read("SELECT eventid, event, title, customfields, dateline_from from " . TABLE_PREFIX . "event WHERE calendarid='".$calendarid."' $and order by dateline_from ASC LIMIT $per_page");
$count=0;
if(!$db->num_rows($getevents))
{
}
else
{
WHILE ($events=$db->fetch_array($getevents))
{
$eventdetails=$events['event'];
$eventdetails=substr($eventdetails, 0, 300);
$eventdetails .= "......";
$customfield=$events['customfields'];
$customfield = str_replace('a:0:{}', '', $customfield );
$customfield =strstr ($customfield, '"');
$customfield = str_replace('"', '', $customfield );
$customfield = str_replace(';}', '', $customfield );

$dtitle=$events['title'];
$did=$events['eventid'];
$date = vbdate('d-m-y',$events['dateline_from'], false,true,false,true);
$dateext = vbdate('l jS F Y',$events['dateline_from'], false,true,false,true);
if ($count = 2){$class="alt2";}else {$class="alt1";}
$year=date("Y");
$pagetitle = $f;
$pagetitle .= " ";
$pagetitle.=$year;
$eventbits .="";

$dateext = htmlentities($dateext);
$eventdetails = htmlentities($eventdetails);


$eventbitsExt .="
<item>
<title>$dateext</title>
<description><![CDATA[$eventdetails]]></description>
<link><![CDATA[http://www.bidefordmarket.co.uk/calendar.php?do=getinfo&e=$did&c=$calendarid]]></link>
<guid><![CDATA[000000$did]]></guid>
<pubDate><![CDATA[$sdate]]></pubDate>
</item>
";
$count++;
}
}


$bidefordmarketeventlist = "bidefordmarketeventlist.rss";
$fh = fopen($bidefordmarketeventlist, 'w') or die("can't open file");
fwrite($fh, "<?xml version='1.0' encoding='UTF-8' ?>
<rss version='2.0'>
<channel>
<title>Bideford Market Events</title>
<description>This is the RSS feed for Bideford Markets Latest Events</description>
<link>http://www.bidefordmarket.co.uk</link>
<lastBuildDate>$sdate</lastBuildDate>
<pubDate>$sdate</pubDate>
<ttl>1800</ttl>
");

//$eventbitsExt = str_replace("?", "?", $eventbitsExt);
//$eventbitsExt = str_replace("&", "&", $eventbitsExt);

$strfinda .= chr(150);
$eventbitsExt = str_replace($strfinda, " ", $eventbitsExt);


fwrite($fh, $eventbitsExt);
fwrite($fh, "</channel>
</rss>");
fclose($fh);


$db->free_result($getevents);
unset($events);
$output=ob_get_contents();
ob_end_clean();


yes i know i probably look very tatty in the way i did things, but i am a novice with php :)

89Brian
02-01-2013, 04:21 PM
Did anyone ever figure out how to add a cut off date for events to be displayed?

I'd like to have a 20 or 30 day cut off on displayed events.

fxdigi-cash
05-06-2013, 03:22 AM
Thanks for the mod!

I believe it would be more interesting if you added jquery count down till event time... what do you think?

PAPPACLART
01-05-2014, 04:42 AM
support for 4.2.2? As no longer works for me

Daniel
10-12-2014, 08:18 AM
Doesn't seem to work for 4.2.2

oldfan
04-15-2023, 03:26 PM
works for 4.2..6 php 7.2

anyway to get it to show like every april 12, multiple years?