vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin CMS Widgets - Upcoming Events (https://vborg.vbsupport.ru/showthread.php?t=231365)

tomsch 06-16-2011 12:13 AM

Code:

ob_start();
global $db,$vbulletin;


$mydate =  mktime(0, 0, 0, date("m"), date("d")-1, date("Y"));
$show_count =10;

$query = sprintf("SELECT * FROM ".TABLE_PREFIX."event WHERE visible = 1 AND (dateline_from >= '$mydate' || (  dateline_from >= '$mydate' AND dateline_to <= '$mydate' )) ORDER BY dateline_from ASC LIMIT $show_count");

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

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

    if($event['dateline_to'] == 0 )
    {
        $format = sprintf("On %s",vbdate('D M jS Y',$event['dateline_from'],false,true,false,true));
    } else {
        $format = sprintf("From %s to %s",vbdate('D M jS Y',$event['dateline_from'],false,true,false,true),vbdate('jS M Y',$event['dateline_to'],false,true,false,true));
    }
     
    $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();

ok good catch on the limit not work its fixed in this version i'm cleaning up the code a little to make it easier to setup.

htan68 06-16-2011 02:06 PM

@tomsch
Thank you, this works for my page with +8 timezone.

Eq4bits 06-24-2011 05:08 PM

Quote:

Originally Posted by top dogs 360 (Post 2208258)
Okay this works for me and should fix anyone's problem whether it is ranged events or single day events or the 1 day early problem.


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

$tz_offset = 86400;
if($event['dateline_to'] == 0 )
{
$format = sprintf("On %s",date('M jS Y',($event['dateline_from']+$tz_offset)));
} else {
$format = sprintf("From %s to %s",date('h:i A M jS Y',($event['dateline_from'])),date('h:i A M jS 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();

It is set to cut off at 5 events, you can adjust that via $show_count = 5.

It has a timezone offset of 1 day via seconds for the 1 day early issue here $tz_offset = 86400

Its format for date is set to Time, Date, Month, and Year via here $format = sprintf("From %s to %s",date('h:i A M jS Y',($event['dateline_from']+$tz_offset)),date('h:i A M jS Y',($event['dateline_to'])));.

And here for the all day events that do not include time of day ; $format = sprintf("On %s",date('M jS Y',($event['dateline_from']+$tz_offset)));
} else {

I used the above code but the current date & it's events are not showing; just the next day's date & it's events. Any ideas?

tomsch 06-24-2011 10:26 PM

Quote:

Originally Posted by Eq4bits (Post 2212284)
I used the above code but the current date & it's events are not showing; just the next day's date & it's events. Any ideas?

yes use the last code i posted its working for all cases

Eq4bits 06-25-2011 01:51 AM

Thanks muchly. Don't know how I missed that post, I *thought* I'd read all 16 pages ;)
Would you happen to know of a way to either put the 'from/to' *above* the 'event'? Or maybe a horizontal bar/separator between each event in the list? I've been playing with it but no luck.

Eq4bits 06-25-2011 04:21 AM

Ugh. Hate to bug ya but.... everything is working/showing properly *except* the 'to' date... it's showing 1 day extra.
i.e. date range is 12:01 AM July 1 2011 to 11:59 PM July 7 2011
yet in widget it's showing as
Quote:

From Fri Jul 1st 2011 to 8th Jul 2011

tomsch 06-26-2011 07:12 PM

Quote:

Originally Posted by Eq4bits (Post 2212461)
Ugh. Hate to bug ya but.... everything is working/showing properly *except* the 'to' date... it's showing 1 day extra.
i.e. date range is 12:01 AM July 1 2011 to 11:59 PM July 7 2011
yet in widget it's showing as

thanks for the bug report i'll get it resolved shortly.

i also added to my version the ability to have and image that is in the event to be displayed with each item.

i also added the capability to add a divideing line between events i just need a horizontal line image of the right size.

Eq4bits 06-26-2011 10:14 PM

Another question....
If an event say lasts a week and the 'current' date/time is during that week (but after the 'start' date/time) the event isn't showing even though the event isn't 'completed'.

Eq4bits 06-26-2011 10:20 PM

https://vborg.vbsupport.ru/external/2011/06/12.png
Here is a horizontal line that is 2px x 150px
If it needs to be a different dimension let me know ;)

tomsch 06-26-2011 11:21 PM

Quote:

Originally Posted by Eq4bits (Post 2213251)
Another question....
If an event say lasts a week and the 'current' date/time is during that week (but after the 'start' date/time) the event isn't showing even though the event isn't 'completed'.

another good catch

thanks


All times are GMT. The time now is 10:03 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.01671 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete