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)

TheChief 05-16-2011 09:55 PM

What I'm after is the upcoming events to be displayed.

And (if ranged) the start and end times

In english

No historical events to be displayed

Sorry to be a pain in the ass

tomsch 05-16-2011 10:20 PM

ok the code in my earlier post does that. how ever it only displays the date are you say you want the time displayed also??

TheChief 05-17-2011 05:06 AM

If you could that'd be great :)

TheChief 05-17-2011 05:13 AM

This is the code i'm currently using.......


Quote:

ob_start();

$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'] == 0 )
{
$datefrom = date('j',$event['dateline_from']);
$datefrom = $datefrom+1;
$format = sprintf("On ".$datefrom."th %s",date('M Y',$event['dateline_from']));
} else {
$datefrom = date('j',$event['dateline_from']);
$datefrom = $datefrom + 1;
$dateto = date('j',$event['dateline_to']);
$dateto = $dateto + 1;
$format = sprintf("From ".$datefrom."th %s to ".$dateto."th %s",date('M Y',$event['dateline_from']),date('M Y',$event['dateline_to']));
}

$output_bits .= sprintf('
<div class = "cms_widget_post_bit"><center><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></center>
</div>
',$event['eventid'],$event['title'],$format);

}
$output = $output_bits;

ob_end_clean();


This does everything but the time..............and it seems to remove a planned event for the day as soon as the clock turns midnight (i.e. if there is a meet planned for the 17th May then as the clocks turn from 23:59 (tues) - 00:00 (weds) the event is removed

tomsch 05-18-2011 12:15 AM

Code:

ob_start();
global $db,$vbulletin;

$mydate3 =  mktime(0, 0, 0, date("m"), date("d"), date("Y"));

//  %d
$show_count =10;

$query = sprintf("SELECT * FROM ".TABLE_PREFIX."event WHERE visible = 1 AND (dateline_from >= '$mydate3' || (  dateline_from >= '$mydate3' 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'] == 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 h:i:s A',$event['dateline_from'],false,true,false,true),vbdate('jS M Y h:i:s A',$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;


this will display the times for the Range events. But there is a small catch when you enter the range event leave the time zone setting to GMT.

i left off the time for the all day event as its always the same time because of the way its stored.

i also fixed a bug in my code the mydate3 variable was commented out for my fixed date.

TheChief 05-19-2011 05:29 AM

Thanks for this..............fantastic stuff

Works perfect and is exactly what i was after

Have a huge bag of kudos :)

TransAmDan 05-27-2011 01:40 PM

Quote:

Originally Posted by otterag (Post 2168332)
first i want to say that is a great mod. i have a few questions though.
- Is there a way to change the information that is displayed in the widget box. instead of having it show the date ranges of the event i would like to see it display the Date of the next event upcoming along with the day of the week and the start time

Example
Currently it shows
"Name of Event"
"From 4th March 2011 to 4th July 2011"

What i would like it to show would be
"Name of Event"
"Friday, March 4th @ 3:00pm"

I'm having the same issue and also looking for a solution to this.

top dogs 360 06-15-2011 09:11 PM

Quote:

Originally Posted by tomsch (Post 2196969)
Code:

ob_start();
global $db,$vbulletin;

$mydate3 =  mktime(0, 0, 0, date("m"), date("d"), date("Y"));

//  %d
$show_count =10;

$query = sprintf("SELECT * FROM ".TABLE_PREFIX."event WHERE visible = 1 AND (dateline_from >= '$mydate3' || (  dateline_from >= '$mydate3' 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'] == 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 h:i:s A',$event['dateline_from'],false,true,false,true),vbdate('jS M Y h:i:s A',$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;


this will display the times for the Range events. But there is a small catch when you enter the range event leave the time zone setting to GMT.

i left off the time for the all day event as its always the same time because of the way its stored.

i also fixed a bug in my code the mydate3 variable was commented out for my fixed date.

Two issues, 1) if you leave the time zone to GMT it looks good for the widget but the actual Event shows the event 7 hours behind. Obviously the event creator is GMT -7. Isn't there a way to incorporate a offset time zone in the code?
2) The code is working fine but it shows all events in the widget not the 10 as the cutoff is set for. Can that be fixed?

top dogs 360 06-15-2011 09:52 PM

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 am still debating on dropping the Year form the widget since 99% of the time the next 5 events are in the same year anyway. To do that simply drop the Y from the M jS Y or h:i A M jS Y


See it live, 3rd block from the top on the right column. http://xboxhounds.com

I'm simply an amateur but I'm learning with as I go.

Mooff 06-15-2011 11:25 PM

You can customize the date however you want, see the php documentation:
http://www.php.net/manual/en/function.date.php

The time offset should be in the database-query, not in your output date.

As for showing Users their local time. I thought about changeing the widget that way, but then i think i can't use the cms-widget-cache anymore on this particular widget. I just can't imagine the widget beeing created for multiple timezones in the cache. ;)
Second issue with local time is the utc-column in the event-db-table. You need to correct for that value as well, depending on which timezone the user chose upon adding the event.


---------------------------------

Thanks to the creator of the widget. Great work, great idea. :)


All times are GMT. The time now is 04:41 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.01544 seconds
  • Memory Usage 1,763KB
  • 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
  • (2)bbcode_code_printable
  • (3)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