Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons

Reply
 
Thread Tools
UpComing Events SideBlock/Bar With/Without Image Details »»
UpComing Events SideBlock/Bar With/Without Image
Version: 1.10, by ProFifaLeagues ProFifaLeagues is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Category: vBulletin Forum Sideblocks - Version: 4.0.0 Rating:
Released: 11-05-2010 Last Update: Never Installs: 96
Re-useable Code Translations  
No support by the author.

Upcoming Events in Forum Block/Sidebar



Add the "Upcoming Events" in the forum side block
(Added as a few people seem to have issues with other mods the same)

Start by logging into your Admin cp

Goto Forums and moderators - Forum Blocks Manager and add a new Block.
Call the Block Upcoming Events(Or what ever suits your liking)
Set the block to Active
And use PhP Format.

Now add the content below :
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);   

$event_get vB::$db->query_read($query); 

$output_bits ''
while(
$event vB::$db->fetch_array($event_get)) { 

     if(
$event['dateline_to'] == 
     { 
         
$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'])); 
     } 
      
     
$output_bits .= sprintf(
        <div class = "cms_widget_post_bit"><h4 class="cms_widget_post_header"><a href="calendar.php?do=getinfo&e=%d">%s</a></h4> 
            <p class="cms_widget_post_content">%s</p> 
        </div> 
        '
,$event['eventid'],$event['title'],$format); 


$output $output_bits


ob_end_clean(); 
return 
$output
Then just make sure the template to use is set to Block_HTML

This will then show the latest upcoming event from your calendar with multi-day events shown until the last day of the event.



Update Thanks to dcuellar
What this does is add a picture centered above the upcoming event. The picture is uploaded to 'images/' as event.jpg. You can change that to whatever you want. It also corrects the issue I had with the date. It's now projecting the proper date.


NOTE:
I changed the number of events to display to 1.
I do not need the range on my forum so I did not test that part.
Here you go for those interested (change what's in Red):
PHP Code:
ob_start(); 


//  %d 
$show_count 1

$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);   

$event_get vB::$db->query_read($query); 

$output_bits ''
while(
$event vB::$db->fetch_array($event_get)) { 

     if(
$event['dateline_to'] == 
     { 
         
$format sprintf("On %s%s %s %s",date("j",$event['dateline_from'])+1date("S",$event['dateline_from']), date("M",$event['dateline_from']), date("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'])); 
     } 
      
     
$output_bits .= sprintf(
        <div class = "cms_widget_post_bit"><center><a href="calendar.php?do=getinfo&e=%d"><img src="http://www.YourForum.com/forum/images/event.jpg" width="200px" alt="Upcoming Event"/><h4 class="cms_widget_post_header">%s</a></h4> 
            <p class="cms_widget_post_content">%s</p></center>
        </div> 
        '
,$event['eventid'],$event['title'],$format); 


$output $output_bits


ob_end_clean(); 
return 
$output
Thanks go to cybaGirl for this fix:
Anyone who has the date showing as the day before can use this code in there forum block.

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);   

$event_get vB::$db->query_read($query); 

$output_bits ''
while(
$event vB::$db->fetch_array($event_get)) { 

     if(
$event['dateline_to'] == 
     { 
         
$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'])); 
     } 
      
     
$output_bits .= sprintf(
        <div class = "cms_widget_post_bit"><center><a href="calendar.php?do=getinfo&e=%d"><img src="http://www.YourForum.com/forum/images/event.jpg" width="200px" alt="Upcoming Event"/><h4 class="cms_widget_post_header">%s</a></h4> 
            <p class="cms_widget_post_content">%s</p></center>
        </div> 
        '
,$event['eventid'],$event['title'],$format); 


$output $output_bits


ob_end_clean(); 
return 
$output

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
3 благодарности(ей) от:
ggrimes620, NoMatt3r, Toxic2

Comments
  #112  
Old 01-11-2013, 07:29 PM
zapiy zapiy is offline
 
Join Date: Jul 2008
Posts: 139
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can i use this on VBadvanced as a module is some way please?
Reply With Quote
  #113  
Old 02-05-2013, 05:56 PM
CptBogo CptBogo is offline
 
Join Date: May 2007
Location: ATL
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i have modified this a little bit for my forum and i thought i would share.

instead of
PHP Code:
if($event['dateline_to'] == 
     { 
         
$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'])); 
     } 
i used
PHP Code:
$format sprintf("On %s at %s"vbdate('jS M, Y',$event['dateline_from']), vbdate('g:i A'$event['dateline_from'])); 
this does a couple things different.

first i changed the format to look like 'On 5th Feb, 2013 at 8:00 PM'. the end date wasnt as important to us as the time the event started so i added the time and removed the end date.

second it uses the vbulletin 'vbdate' function instead of the PHP 'date' function. this will automatically change the date to the users timezone instead of using the servers timezone. remember to set 'Cache Time' to 0 in the forum block settings or else it will cache someone elses timezone and be incorrect for every other user.

hope this helps someone else trying to do something similar.

and a screenshot of how it looks on my forum.
Reply With Quote
Благодарность от:
Alibass
  #114  
Old 02-06-2013, 03:02 AM
Filip Filip is offline
 
Join Date: Feb 2007
Location: Sweden, Gothenburg
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a simple way to have the date being displayed in a other language than english?
Reply With Quote
  #115  
Old 02-06-2013, 01:20 PM
rhody401's Avatar
rhody401 rhody401 is offline
 
Join Date: Feb 2012
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I like the changes you made a couple posts before this one(VBDATE), but it still seems to show one day earlier than the scheduled date. (for all events on my calendar)

I have the cache set to 0, etc.

Any ideas why? Are you having the same issue?
Reply With Quote
  #116  
Old 02-06-2013, 06:36 PM
CptBogo CptBogo is offline
 
Join Date: May 2007
Location: ATL
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Filip View Post
Is there a simple way to have the date being displayed in a other language than english?
if the user logged into vbulletin has another language set in their profile the vbdate function should adjust it for their language. you might want to change the format the date is displayed in though vbdate("format here", time())
if you are familiar with PHP you might want to have a look at these functions:
http://www.php.net/manual/en/function.setlocale.php
http://www.php.net/manual/en/function.strftime.php
they work together, you use the first function to set the language you want to use and the second function creates the date string based on the language you defined in the first function. note that the vbdate function includes those 2 functions in it.


Quote:
Originally Posted by rhody401 View Post
I like the changes you made a couple posts before this one(VBDATE), but it still seems to show one day earlier than the scheduled date. (for all events on my calendar)

I have the cache set to 0, etc.

Any ideas why? Are you having the same issue?
i did not have this issue. however it looks like others have been experiencing it. there are a couple solutions in this thread. but the easiest is probably:
PHP Code:
$format sprintf("On %s at %s"vbdate('jS M, Y',$event['dateline_from']+86400), vbdate('g:i A'$event['dateline_from'])); 
this simply adds 1 day(in seconds) to the events timestamp so when it gets the formatted date string its +1 day


also for those interested i have updated my own code to show 'Today', 'Tomorrow', etc instead of the day, month and year. if the date is more then a week in the future it will display the full day, month, year format(February 6th, 2013).

PHP Code:
if(vbdate("dmY"$event['dateline_from']) == vbdate("dmY")) //it is today.
    
{
        
$format sprintf("Today at %s"vbdate('g:i A'$event['dateline_from']));
    }
    elseif(
vbdate("dmY"$event['dateline_from']) == vbdate("dmY"time() + 86400)) //it is tomorrow
    
{
        
$format sprintf("Tomorrow at %s"vbdate('g:i A'$event['dateline_from']));
    }
    elseif(
$event['dateline_from'] < (time() + 604800)) //1 week = 604800 //it is this week
    
{
        
$format sprintf("%s at %s"vbdate('l',$event['dateline_from']), vbdate('g:i A'$event['dateline_from']));
    }
    else
    {
        
$format sprintf("%s at %s"vbdate('l, F jS',$event['dateline_from']), vbdate('g:i A'$event['dateline_from']));
    } 




Edit: I have discovered an issue where full day events that do not have a start time specified dont display correctly. for example the last event in my screenshot, "Starcraft II Risk", should start at 12AM on Saturday and not on Friday. i do not currently have a way to fix this but when i do i will post an update.
Reply With Quote
Благодарность от:
ProFifaLeagues
  #117  
Old 02-22-2013, 10:59 PM
ITMerc ITMerc is offline
 
Join Date: Feb 2013
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi folks! How/where would you modify the code to insert a page break so you'd have an empty line between the date of the first event and the description/title of the NEXT event... I want to visually separate them.
Reply With Quote
  #118  
Old 03-04-2013, 10:01 AM
Hawkinz Hawkinz is offline
 
Join Date: Feb 2012
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

My block doesn't show up when PHP is selected. Any ideas? cheers
Reply With Quote
  #119  
Old 03-21-2013, 03:27 PM
rhody401's Avatar
rhody401 rhody401 is offline
 
Join Date: Feb 2012
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have modified this a bit to make it in a format for USA Month Day Year, and some other small changes. (my modified code below)

It would be REALLY nice if I could find a way to have it exclude some calendar items that have a specific string of text in the title. I just don't know where to put the hook to make this happen. Any suggestions appreciated! THANK YOU

example: If a calendar event has "BOARD MEETING" anywhere in the TITLE, it gets overlooked/ignored by this code. It displays everything else, but these events.

Here is my (current/modified from above) code:
PHP Code:
ob_start(); 

//  %d 
$show_count 9

$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);   

$event_get vB::$db->query_read($query); 

$output_bits ''
while(
$event vB::$db->fetch_array($event_get)) { 

    if(
$event['dateline_to'] == 
     { 
         
$format sprintf(" "); 

//changed code 2/6/13  adds a day  to fix issue, and reformat for USA m/d/y
$format sprintf("On %s"vbdate('M jS, Y',$event['dateline_from']+86400), vbdate('g:i A'$event['dateline_from'])); 

     } else { 
         
$format sprintf("From %s to %s",vbdate('M jS',$event['dateline_from']),vbdate('M jS Y',$event['dateline_to'])); 
     } 
      
     
$output_bits .= sprintf(
      <div class = "cms_widget_post_bit"><center><a href="calendar.php?do=getinfo&e=%d"><h4 class="cms_widget_post_header"><font size="2">%s</font></a></h4> 
            <p class="cms_widget_post_content"><font size="1">%s </font></p><p><font size="1">&nbsp;</font></p></center> 
        </div> 
        '
,$event['eventid'],$event['title'],$format); 


$output $output_bits

ob_end_clean(); 
return 
$output
Thanks in advance if anyone has the time to look at this and give some advice.

Much appreciated! :up:
Rhody
Reply With Quote
  #120  
Old 04-01-2013, 12:00 PM
CptBogo CptBogo is offline
 
Join Date: May 2007
Location: ATL
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rhody401 View Post
I have modified this a bit to make it in a format for USA Month Day Year, and some other small changes. (my modified code below)

It would be REALLY nice if I could find a way to have it exclude some calendar items that have a specific string of text in the title. I just don't know where to put the hook to make this happen. Any suggestions appreciated! THANK YOU

example: If a calendar event has "BOARD MEETING" anywhere in the TITLE, it gets overlooked/ignored by this code. It displays everything else, but these events.

Here is my (current/modified from above) code:


Thanks in advance if anyone has the time to look at this and give some advice.

Much appreciated! :up:
Rhody
PHP Code:
ob_start();  

//  %d  
$show_count 9;  

$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);   

$event_get vB::$db->query_read($query);  

$output_bits '';  
while(
$event vB::$db->fetch_array($event_get))
{  

    if(!
strpos($event['title'], "BOARD MEETING")) // do not show event
    
{
    
        if(
$event['dateline_to'] == )  
        {  
            
$format sprintf(" ");  
    
            
//changed code 2/6/13  adds a day  to fix issue, and reformat for USA m/d/y 
            
$format sprintf("On %s"vbdate('M jS, Y',$event['dateline_from']+86400), vbdate('g:i A'$event['dateline_from'])); 
        
        }
        else
        {  
            
$format sprintf("From %s to %s",vbdate('M jS',$event['dateline_from']),vbdate('M jS Y',$event['dateline_to'])); 
        }  
           
        
$output_bits .= sprintf('  
          <div class = "cms_widget_post_bit"><center><a href="calendar.php?do=getinfo&e=%d"><h4 class="cms_widget_post_header"><font size="2">%s</font></a></h4>  
                <p class="cms_widget_post_content"><font size="1">%s </font></p><p><font size="1">&nbsp;</font></p></center>  
            </div>  
            '
,$event['eventid'],$event['title'],$format);  
            
    }

}
 
$output $output_bits;  

ob_end_clean();  
return 
$output
i have added a simple check if(!strpos($event['title'], "BOARD MEETING")) which says if the title does not contain BOARD MEETING. if it does have BOARD MEETING it skips the event and moves to the next one.

i havnt tested it but it should work.
Reply With Quote
  #121  
Old 04-01-2013, 01:45 PM
rhody401's Avatar
rhody401 rhody401 is offline
 
Join Date: Feb 2012
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you thank you thank you!

I had to take out the first few characters on top, and it is case sensitive, but very workable for what i'm trying to fix. I will fix the calendar entries to be the correct case, so they get ignored.

It does work!

Rhody
Reply With Quote
Reply

Thread Tools

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 07:05 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04799 seconds
  • Memory Usage 2,434KB
  • Queries Executed 28 (?)
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
  • (9)bbcode_php
  • (3)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
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (5)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete