Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Countdown to Calendar Event Details »»
Countdown to Calendar Event
Version: 1.01, by JohnKF JohnKF is offline
Developer Last Online: Oct 2013 Show Printable Version Email this Page

Category: vBulletin CMS Widgets - Version: 4.0.6 Rating:
Released: 10-14-2010 Last Update: Never Installs: 57
Template Edits
Re-useable Code Additional Files Translations  
No support by the author.

This widget picks up the next 2 events from a calendar of your choice.

It displays a countdown to the first event then once the first event has arrived it begins a countdown to the second event. The only reason for picking up two events is that someone may visit the page close to the end of the first event then see the no event message. By picking up two events such a visitor will see the countdown to the second event start.

To install...

From the ZIP file, extract eventcountdown.js and copy it to your site.

Navigate to AdminCP -> Style & Templates -> Style Manager -> Edit Template
Double click the headinclude template to edit it and add the following just above the first <script tag you find...
HTML Code:
<script src="scripts/eventcountdown.js" type="text/javascript"></script>
...the above assumes you have copied eventcountdown.js file in to a folder called scripts. Adjust the src path to wherever you have placed the .js file.

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

PHP Code:
ob_start();
global 
$db,$vbulletin;
$event_calendarid="1";
$no_events_message="<div style='width: 100%; text-align: center; font-weight: bold'>There are no events.</div>";
$today_date mktime(000date(date("m")), date(date("d")),  date(date("y")));
$and=" and dateline_from > '".$today_date."'";

$getevents=$db->query_read("SELECT eventid, title, dateline_from from " TABLE_PREFIX "event WHERE calendarid='".$event_calendarid."' $and order by dateline_from ASC LIMIT 2");
$count=1;
if(!
$db->num_rows($getevents))
{
echo 
$no_events_message;

else
{
echo 
"<script type='text/javascript'>\n";
WHILE (
$events=$db->fetch_array($getevents))
{
$event_title=$events['title'];
$event_date vbdate('U',$events['dateline_from'], false,true,false,true)-vbdate('U');
if(
$count==1)
{
echo 
"var CountDownTimer=new CountDown('CountDownToChange',1,'".$event_title."<br />','".$event_date."','ywdhms',1)\n";
}
else
{
echo 
"CountDownTimer.AddNewEvent('".$event_title."<br />','".$event_date."','ywdhms',".$count.")\n";
}
$count++;
}
}
echo 
"CountDownTimer.DisplayTime(FormatResults)\n";
echo 
"</script>\n";
$db->free_result($getevents);
unset(
$events);
$output=ob_get_contents();
ob_end_clean(); 
To create a forum block...
  1. Navigate to AdminCP -> Forums & Moderators -> Forum Blocks Manager
  2. Click the Add Block button
  3. From the drop down list select Custom HTML/PHP
  4. Click the Continue button
  5. Give the block a title (e.g. Event Countdown) and a short description
  6. Set the cache time to 1 minute
  7. In Content Type select PHP
  8. In Content paste the PHP code above in to the text box
  9. Click the Save button

You can set the value for $event_calendarid to the calendar that you want countdown events to come from. Change $no_events_message to the HTML you want to have appear when there are no events left in the selected calendar.

This is the first widget I've written so if you spot any errors or improvements that can be made then please let me know.

If you have an all day event in the calendar the countdown is to the begining of that day. Add a ranged event to the calendar for an exact time. Also, allow for any changes that may occur if a change to or from DST occurs.

Added ob_start(); to beginning of script (17th Oct, 2010)

To have a picture make the Title of the event in the calendar the HTML to display the picture. For example...
HTML Code:
Your Event<br /><img src="images/picture.gif" width="140" height="130" alt="">
...which shows as the text above in the calendar title, but displays as text and a picture in the countdown.

Download Now

File Type: zip eventcountdown.zip (1.6 KB, 389 views)

Screenshots

File Type: jpg eventcountdown.jpg (8.2 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 10-16-2010, 09:57 AM
sadiq6210 sadiq6210 is offline
 
Join Date: Sep 2005
Posts: 684
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks ..
Reply With Quote
  #13  
Old 10-16-2010, 07:58 PM
betts02's Avatar
betts02 betts02 is offline
 
Join Date: Jun 2009
Posts: 910
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey buddy,

You're missing an ob_start at the front of this script. Recommend you add it in, otherwise the block will break the script that started before it as well as itself.
Reply With Quote
  #14  
Old 10-16-2010, 08:50 PM
ahmedipa ahmedipa is offline
 
Join Date: Feb 2009
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

nice one thank you very much
Reply With Quote
  #15  
Old 10-17-2010, 01:12 AM
trophyrider trophyrider is offline
 
Join Date: Apr 2009
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The script works fine in the forum block area if you add:

ob_start();

at the beginning of the php script.
Reply With Quote
  #16  
Old 10-17-2010, 01:13 AM
trophyrider trophyrider is offline
 
Join Date: Apr 2009
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by trophyrider View Post
The script works fine in the forum block area if you add:

ob_start();

at the beginning of the php script.
See example at http://www.sporttouring.us
Reply With Quote
  #17  
Old 10-17-2010, 02:42 AM
CharlieDelta CharlieDelta is offline
 
Join Date: Apr 2010
Posts: 616
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by trophyrider View Post
I can confirm this works as well.
Thank you.
Reply With Quote
  #18  
Old 10-17-2010, 06:58 AM
betts02's Avatar
betts02 betts02 is offline
 
Join Date: Jun 2009
Posts: 910
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by betts02 View Post
Hey buddy,

You're missing an ob_start at the front of this script. Recommend you add it in, otherwise the block will break the script that started before it as well as itself.
Quote:
Originally Posted by trophyrider View Post
The script works fine in the forum block area if you add:

ob_start();

at the beginning of the php script.
Quote:
Originally Posted by trophyrider View Post
As i stated then ?

Also looking more into this

If you post and event it shows up
But if you then post an event before the first event it does not display

Will get it working myself anyway mate cheers
Reply With Quote
  #19  
Old 10-17-2010, 11:32 AM
JohnKF JohnKF is offline
 
Join Date: Oct 2010
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for that advice about ob_start();
It's my first script you know
Reply With Quote
  #20  
Old 10-17-2010, 11:35 AM
JohnKF JohnKF is offline
 
Join Date: Oct 2010
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by betts02 View Post
As i stated then ?

Also looking more into this

If you post and event it shows up
But if you then post an event before the first event it does not display

Will get it working myself anyway mate cheers
I think it may be because it's cached the first event. I usually clear the CMS cache whenever I change anything just to be sure. If you find another cause though please let me know; thanks.
Reply With Quote
  #21  
Old 10-18-2010, 05:49 PM
betts02's Avatar
betts02 betts02 is offline
 
Join Date: Jun 2009
Posts: 910
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Something is not correct here

I have an event in 2 days time, Yet its showing the event is due NOW

Will look into this myself but if you manage to figure it out post up dude
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:59 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04534 seconds
  • Memory Usage 2,356KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_html
  • (1)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (2)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete