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 Details »»
Upcoming Events
Version: 1.00, by ngcoders ngcoders is offline
Developer Last Online: Sep 2012 Show Printable Version Email this Page

Category: vBulletin CMS Widgets - Version: 4.0.0 Rating:
Released: 12-27-2009 Last Update: Never Installs: 348
Auto-Templates
 
No support by the author.

Upcoming Events

Released 28/12/2009
By Vikas - http://www.ngcoders.com

Installation
  • Goto Admincp->vBullietin CMS->Widgets->Create New Widget
  • Choose PHP Direct Execution as Widget's Type
  • Place a Title. eg Upcoming Events. Keep it short as this is what will appear as title on your pages.
  • Click Save
  • Click Configure on the right of the new created widget.
  • Remove the default code that appears. Be sure to not leave behind even a single letter.
  • Copy and Paste the code that you can find below.
  • Leave the template name as is (vbcms_widget_execphp_page)
  • Click Save
  • Goto Admincp->vBullietin CMS->Layout Manager
  • Click Go on the Default Layout
  • Add the Widget to your Layout
  • Click Save
  • That's all !!

PHP Code

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

Screenshots

File Type: jpg events.jpg (14.8 KB, 0 views)

Show Your Support

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

Comments
  #152  
Old 07-26-2010, 05:48 AM
Testing123 Testing123 is offline
 
Join Date: Dec 2002
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe we could kill two birds with one stone (so to speak). Looking at the code line by line, people knowledgeable in php and vB could explain what's going on with that code line. Maybe we could learn a few things and end up with a needed widget. :-)
I'll start, using Stadler's code (I hope you don't mind, Stader).

Please jump in with any/all info and/or insight you can offer and don't hesitate correct any errors with my comments/logic. Thanks!
In php, we use // to make a single-line comment or /* and */ to make a large comment block.
I'll use /*...*/ for my comments as there is a line in the code that uses // and I'm not sure why it's there.
Comments will be placed before (above) the line(s) of code they reference.

-+-+-+-+-+-+-+-+
UPDATE – July 31, 2010
I've edited a few areas in my comments as I've gained a bit more insight into php and the code.
Hope this helps someone. And I really hope others will join in!
-+-+-+-+-+-+-+-+

OK, here we go:

/* Since there is a parentheses after ob_start, this is obviously a function call. */
/* I guess vB needs this to indicate the start of a php widget */

ob_start();


/* What is this used for? // is used to denote a single line comment */
/* (i.e. not processed as part of the program by php interpreter). */
/* It's not indicating anything I can see in the code. */
/* Why is it included? */

// %d

/* Obviously $show_count is a variable, set to a value of 5 as seen */
/* in the set up of the database query line that follows this one. */

$show_count = 5;


/* This sets up a MySQL database query with the results placed in the $query variable. */
/* sprintf is used to write a formatted string to a variable (in this case, $query). */
/* Variables, values, strings, etc. are integrated into the string using */
/* conversion specifications which are passed in as arguments to the */
/* sprintf function. E.g. you can pass in a value and require that value to be an integer. */
/* Apparently, sprintf is commonly used in SQL calls to 'sanitize' the string. */

/* The argument parameters will be inserted at the percent (%) signs in the main string. */
/* In the following line, 2 percent formatters and 2 arguments are used. */
/* The arguments are the variables/strings/etc. that are placed at the end of the line, */
/* separated by commas. */
/* TIMENOW and $show_count are the 2 arguments in the following line. */

/ * %1\$d */
/* This is replaced by the TIMENOW variable and formatted as a signed decimal number. */
/* %1 says to use the first argument and $d says to make it a signed decimal number. */
/* A backslash (\) is used to separate the argument identifier from the format identifier. */

/* %2\$d */
/* This is replaced by the $show_count variable and formatted as a signed decimal number. */
/* %2 says to use the second argument. */

/* || means 'or' in php speak */
/* AND means 'and' in php speak */

/* I still don't (as yet) fully understand the date formatting. */

$query = sprintf("SELECT * FROM ".TABLE_PREFIX."event WHERE visible = 1 AND (dateline_from > '%1\$d' || ( dateline_from > '%1\$d' AND dateline_to < '%1\$d' ) || (dateline_to = 0 AND DATE(FROM_UNIXTIME(dateline_from)) = DATE(FROM_UNIXTIME(%1\$d)))) ORDER BY dateline_from ASC LIMIT %2\$d",TIMENOW,$show_count);


/* This fetches the info from the database using the string built */
/* and stored in the $query variable. */
/* The results are stored in the $event_get array variable. */
/* Not sure why it's formatted the way it is. */

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


/*This sets the variable $output_bits to double quote character. Why is this needed? */

$output_bits = '';


/* While loop. */
/* $event (which is an array, right?) is the variable used */
/* to store the info retrieved in $event_get. */
/* While will loop until the function returns no more data */
/* (function returns 0 or false). */

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


/*if/else conditional. */
/* Again, date formatting. Expanation here is again needed. :-) */

if($event['dateline_to'] == 0 )
{
$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']));
}


/* sprintf is used again, this time to build a formatted output string. */
/* However, since this is within the loop, doesn't the $output_bits variable */
/* get rewritten each time through the loop? */

/* Wait a sec... the first part of this line is: */
/* $output_bits .= sprintf(' */
/* I notice a dot (.) just before the equals (=) sign. Does this concatenate (add to) */
/* the string with each iteration (instead of rewriting the contents of the variable each time)? */

$output_bits .= sprintf('
<div class = "cms_widget_post_bit"><h4 class="cms_widget_post_header"><a href="calendar.php5?do=getinfo&e=%d">%s</a></h4>
<p class="cms_widget_post_content"> %s</p>
</div>
',$event['eventid'],$event['title'],$format);
}


/* Why is $output equated to $output_bits? */
/* I guess vB internal code uses $output to print out (display) data in the widget, */
/* so a string must be built and then copied to this variable... right? */

$output = $output_bits;


/*This is obviously needed by vB to close the widget and clean up. */
/* ( Companion to ob_start() ). */

ob_end_clean();
Reply With Quote
  #153  
Old 07-31-2010, 03:28 AM
Recronin Recronin is offline
 
Join Date: Jan 2010
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@ngcoders
OMG I love you, this is exactly what I needed.
Reply With Quote
  #154  
Old 08-19-2010, 01:45 AM
sulasno sulasno is offline
 
Join Date: Feb 2010
Posts: 588
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

working in 4.0.6
Reply With Quote
  #155  
Old 08-20-2010, 05:26 PM
FatalCure FatalCure is offline
 
Join Date: Jul 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can someone convert this code to a forum block? If I try using the existing code in a forum block I get the following error.

Fatal error: Class 'vB' not found in /home/public_html/includes/block/html.php(95) : eval()'d code on line 9
Reply With Quote
  #156  
Old 08-20-2010, 05:44 PM
ProFifaLeagues's Avatar
ProFifaLeagues ProFifaLeagues is offline
 
Join Date: Aug 2009
Location: Uk
Posts: 1,191
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Be good to have it in the Forum blocks as well
Reply With Quote
  #157  
Old 08-20-2010, 06:48 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

same code just add at the end
return $output;
Reply With Quote
  #158  
Old 08-21-2010, 08:54 PM
FatalCure FatalCure is offline
 
Join Date: Jul 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ragtek View Post
same code just add at the end
return $output;
I still get Fatal error: Class 'vB' not found in /home/public_html/includes/block/html.php(95) : eval()'d code on line 9
Reply With Quote
  #159  
Old 08-21-2010, 08:57 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what's your code?
Reply With Quote
  #160  
Old 08-22-2010, 12:40 AM
FatalCure FatalCure is offline
 
Join Date: Jul 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ragtek View Post
what's your code?
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
in a forum block as php.
Reply With Quote
  #161  
Old 08-23-2010, 03:41 AM
FatalCure FatalCure is offline
 
Join Date: Jul 2006
Posts: 18
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also single day events do not show if the event is that day, it would be good if it showed the entire day the event was on.
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 12:49 AM.


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.10570 seconds
  • Memory Usage 2,367KB
  • 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_php
  • (2)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
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (2)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)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
  • 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_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