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
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
  #122  
Old 04-01-2013, 07:39 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 had to take out the first few characters on top
im not sure what that means


Quote:
Originally Posted by rhody401 View Post
and it is case sensitive
use stripos instead. that is a case insensitive search instead of the case sensitive strpos
Reply With Quote
Благодарность от:
rhody401
  #123  
Old 04-02-2013, 01:13 PM
rhody401's Avatar
rhody401 rhody401 is offline
 
Join Date: Feb 2012
Posts: 120
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

>I removed the first characters
Quote:
Originally Posted by CptBogo View Post
im not sure what that means


use stripos instead. that is a case insensitive search instead of the case sensitive strpos
Oh what I meant is that it gave an error until i removed this from the start of the snippet: "<?"

It works fine without that at the very top of the code.

I also changed it to stripos, at your suggestion, and tested to confirm that it now works with mixed case.

Thank you so much for taking the time to help me with this. This is one that we use heavily on our forum, to show upcoming meetings and events.

:up:
Reply With Quote
  #124  
Old 04-10-2013, 06:18 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 removed the first characters


Oh what I meant is that it gave an error until i removed this from the start of the snippet: "<?"

It works fine without that at the very top of the code.

I also changed it to stripos, at your suggestion, and tested to confirm that it now works with mixed case.

Thank you so much for taking the time to help me with this. This is one that we use heavily on our forum, to show upcoming meetings and events.

:up:
oops sorry. i forgot to take out the <?. i edited my post to remove it for anyone in the future. and no problem, glad i could help.
Reply With Quote
  #125  
Old 10-04-2013, 10:53 PM
gajinoz gajinoz is offline
 
Join Date: Nov 2011
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just installed this. Seems to work perfectly, thanks, good job.
Reply With Quote
  #126  
Old 04-30-2014, 12:21 PM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I cannot get this working properly. it either shows the wrong date or does not display correctly after trying the fixes.

Can someone share their code they are using with 4.2.2?

i have it working now..I took some of the above fixes and made some changes and it is working now.
Reply With Quote
  #127  
Old 03-25-2015, 12:55 AM
audzilla audzilla is offline
 
Join Date: Oct 2013
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, this is excellent!

Since DST started, though, I've noticed that sometimes events display as an hour later than they should, and sometimes they're fine. By default there's an 'ignore DTS' checkbox that is checked when creating a calendar event, but that doesn't really seem to affect what's displaying on the sidebar widget.

I'm not remotely a coder, but basically I can't figure out the interaction between the calendar's automatic DST stuff and the user profiles and this widget. Any suggestions?
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 08:10 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.04640 seconds
  • Memory Usage 2,338KB
  • Queries Executed 24 (?)
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
  • (3)bbcode_php
  • (4)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
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (7)post_thanks_box
  • (4)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (6)postbit
  • (7)postbit_onlinestatus
  • (7)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